Category: Uncategorized

Create Custom Tool Parts for SharePoint Web Parts

What is a custom tool part ?

The Custom tool part is part of the web part infrastructure, that helps us to create a custom user interface for the web part properties that goes beyond the capabilities of the default property pane.

When do we need a custom tool part ?

Let’s say, If we need to create a web part property of type dropdown, we need to create a custom tool part. This is not supported out-of-box in the web part framework. I’ve the similar requirement of creating a custom web part property of type drop-down, So i went ahead and implemented the custom tool parts. Here are the steps to create a custom tool part.  

 public class SampleToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
    {
        //create an instance of the dropdown control to be used in the custom tool part 
        System.Web.UI.WebControls.DropDownList oDropDown = new System.Web.UI.WebControls.DropDownList();

        // Reference to the parent web part
        SampleWebPart oSampleWebPart = null;

On the constructor method of the tool part class, just set the title of the tool part. In this case i'm going to display the 
vendor names to the user
So i naming the title as select a vendor.
        public SampleToolPart()
        {

            // Set the title for the custom tool part
            this.Title = "Select a Vendor";

        }

        protected override void CreateChildControls()
        {
            try
            {

            //Get the instance of the parent web part on which this tool part is to be hosted
            oSampleWebPart = (SampleWebPart)ParentToolPane.SelectedWebPart; 
            //Get the instance of the current site collection
            SPSite oSPSite = SPControl.GetContextSite(HttpContext.Current);
            //Get the instance of the current site (spweb)
            Guid currentsiteid = SPControl.GetContextWeb(HttpContext.Current).ID;

            using (SPWeb oSPWeb = oSPSite.OpenWeb(currentsiteid))   

                {
In the following few lines of code, i'm reading the list of vendors from the sharepoint custom list 'VendorList' and binding it to the sharepoint custom tool part. 
                    SPList oProviderMaster = oSPWeb.Lists["VendorList"];
                    foreach (SPListItem oSPListItem in oProviderMaster.Items)
                    {

                        string sProviderName = oSPListItem["VendorName"].ToString();
                        oDropDown.Items.Add(sProviderName);
                    }

                }

            // Add the dropdown to the actual toolpart controls
            this.Controls.Add(oDropDown);
            base.CreateChildControls();
            }
            catch (Exception ex)
            {

            }

        }

When the user choses the item from the dropdown of the custom tool part and clicks 'Apply Changes', grab the selected item from 
the dropdown list and assign this value to a public property declared in the parent web part, where the tool part is hosted.
        public override void ApplyChanges()
        {
            try
            {
                if (!(oDropDown.SelectedItem == null))
                {
                    oSampleWebPart.SelectVendor = oDropDown.SelectedValue;
                }

            }
            catch (Exception ex)
            {

               //handle exceptions here
            }            

        }   

    }

 Subscribe to my post

Render Iframes dynamically inside SharePoint Application Pages

There is a requirement to render the publically available web site content inside SharePoint application pages, dynamically based on arbitrary condition. This can be done in two ways. The first option is to use the page viewer web part and dynamically set the url of page viewer using a user control tied to the master page. The second option is to design an application page and render the external content using IFrames. The option of application pages + Iframes is better compared to dynamic page viewer web part way, considering many pros and cons.

The best way to achieve this to have an ASP.NETuser control that hosts the IFrame. Then host the entire user control inside the application page. Because user control gives the more control and flexibility to manipulate the properties of Iframes at run-time, than finding the logical event of ASP.NET page life-cycle and accomplish this task.

.  On the page load of user control, add the src property of the user control

 protected void Page_Load(object sender, EventArgs e)
        {
            this.IFrame1.Attributes.Add("src", ThirdPartyUrl);
        }

 Subscribe to my post

SharePoint Conference 2009 Sessions

The initial list of sessions for SharePoint Conference 2009 to be held in October 2006 at LasVegas is announced. Here is the initial list of session and topics :-

  1. SharePoint 2010 Overview and What’s New
  2. Upgrading to SharePoint 2010
  3. SharePoint 2010 Capacity and Performance Planning
  4. SharePoint 2010 Security and Identity Management: What’s New
  5. Visual Studio 2010 Tools for Office Development
  6. SharePoint 2010 Ribbon, ECMAScript and Dialog Framework Development
  7. Developing with REST and LINQ in SharePoint 2010
  8. Upgrading SharePoint Server 2007 Code to SharePoint 2010
  9. Building Composite Applications with the Microsoft Application Platform
  10. What’s New in Business Connectivity Services (The Business Data Catalog Evolves!)
  11. FAST Search for SharePoint – Capabilities Deep Dive
  12. Advanced Dashboard Creation with Performance Point Services for SharePoint 2010
  13. Overview of Visio and Visio Services for SharePoint 2010
  14. SharePoint 2010 Web Content Management Deep-Dive

We may get more updated sessions down the line.

Power of Host-named Site Collections for url scaling

In SharePoint 2007, we can create two types of site-collections namely path-based site-collections and host-named site collections. The path-based site-collections are more the traditional and more common way of deployment. In Path-based site-collections,  the site-collections are mapped to a managed path that is subordinate to the web application.  The limiation of the path-based site-collection is that i can have only the single host name or hosted URL.  This does not provide great benefit in terms of url scaling.

The host-named site-collections  are created by providing a valid host-header name.

 

 

 

 

 

 

 

 

Offers and Discount on Microsoft Exams

Microsoft is providing a 10% discount on Microsoft Certified Technical Specialist (MCTS), Microsoft Certified IT Professional (MCITP) or Microsoft Certified Professional Developer (MCPD) exams.

Register today with your MVP Certification Promotion Code and enjoy 2 chances to pass a Microsoft Certification Examination* plus a 10% discount! If you fail on your first attempt, you will receive a free retake of the same exam (both exams must be taken by May 31, 2009)**!

Your Unique MVP Certification Promotion Code: IN0E9D9F

From now till March 31, 2009, the microsoft community members can  key in the above MVP Promotion Code at www.learnandcertify.com to obtain a Microsoft Certification Exam Voucher Code at a 10% discount and free retake offer.

Note:-

The Exam Voucher Code is valid for exams taken by May 31, 2009 in India. Note that the limited time offer is valid for Microsoft Certified Technology Specialist (MCTS), Microsoft Certified IT Professional (MCITP) and Microsoft Certified Professional Developer (MCPD) exams only. More information on how to obtain the vouchers and the Terms & Conditions of Usage are available to your community at www.learnandcertify.com.

Passing ASP.NET Server control id to Java script function

I’m recently working on a web application, that invovles creating a Date Picker Control. I’ve decided to leverage calendar javascript and develop them as the textox and an image invoking Calendar Javascript.

My datepicker control looks like the following

Here i’m trying to pass the id of textbox control to the javascript. Javascript could not recognize that.

I’ve learnt that the way to do is as follows

Microsoft MVP Renewed for 2009

I received a wonderful mail from Microsoft yesterday stating that I’ve been renewed as MVP in Windows SharePoint Services for the year 2009. I believe it’s a great honor to be an MVP. I’m entering into second year as MVP. 

It’s really exciting to be associated with this great product “SharePoint”. Because the product itself is fantastic, it has bunch of talented experts in the form of MVPs and support of product team is excellent. Moreover SharePoint community is really vibrant.

I’d to like thank my MVP Lead Abhishek Khant and Bob Fox of ISPA for their support and encouragement. I’d also like to thank people who have attended my talks, read my blogs and participated in the newsgroups and forums.

Last year I was contributing more through online. I’ve big plans for ISPA in India this year. I’d like to contribute more through offline this year.

 

 

 

Azure Services Training Kit – PDC Review

The Azure Services Training Kit will include a comprehensive set of technical content including samples, demos, hands-on labs, and presentations that are designed to help you learn how to use the Azure Services Platform. This initial PDC Preview release includes the hands-on labs that were provided at the PDC 2008 conference. These labs cover the broad set of Azure Services including Windows Azure, .NET Services, SQL Services, and Live Services. It can be downloaded from the following location

http://www.microsoft.com/downloads/details.aspx?FamilyID=413e88f8-5966-4a83-b309-53b7b77edf78&displaylang=en