Using Delegate Controls

Delegate controls are typically used with master pages. They allow you to replace standard SharePoint functionality with your own customizations. When a page is requested, the delegate control looks for controls that are registered for the specific page instance. If it finds them, the control with the lowest sequence number is added in place of the delegate control. By placing a delegate control on a master page, you can designate a location for your control on every page of the site.

The Partner Portal application uses a delegate control to provision the custom global navigation. The default SharePoint master page provides a delegate control for the top navigation data source control. The Partner Portal application takes advantage of this. It reuses the existing master page and modifies it with the custom global navigation code. The ID of the modified delegate control is TopNavigationDataSource. The following code is from the contextualHelp.master file, which is based on default.master file.

<SharePoint:DelegateControl  ControlId="TopNavigationDataSource">


The Partner Portal application replaces the SiteMapDataSource control with another instance of the same control, but it sets different properties. The following code shows how the Partner Portal application sets the control's properties.

<Control Id="TopNavigationDataSource"
         ControlAssembly="System.Web, Culture=neutral, Version=, PublicKeyToken=b03f5f7f11d50a3a">
    <Property Name="ShowStartingNode">false</Property>
    <Property Name="StartingNodeUrl"></Property>
    <Property Name="SiteMapProvider">HierarchicalConfigSiteMapProvider</Property>
    <Property Name="ID">topSiteMap</Property>

You should try to take advantage of all the available delegate controls that are in existing master pages before you decide to create a custom master page. You should also consider placing delegate controls in custom master pages if the implementation may change from one site to another site. This makes the custom master page reusable.


For more information about how to use delegate controls in SharePoint, see Delegate Control (Control Templatization) on MSDN.

Home page on MSDN | Community site