Create delegate control in sharepoint

Today I am going to explain about creating delegate controls in sharepoint.
If you want to see any delegate controls you can visit in the master page. For publishing site there is nightandday.master page which is default master page for the home page of the site.
You can find the following delegate controls in the nightandday.master page.

<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
<SharePoint:DelegateControl ControlId="GlobalSiteLink3-mini" Scope="Farm" runat="server"/>

Before moving to how to create a delegate control, first we look at what is the importance of delegate control.


  • Using the delegate control a developer can customize the SharePoint site controls without editing or even touching the master page.
  • Suppose we created a control for displaying the advertisements in the master page. If we want to keep this control in the master page we need to edit that master page and add all the controls over here. At any time if any mistake happen then whole master page will disturb. To avoid this we have delegate controls.
  • Mapping the delegate control to master page
    After creating the delegate control now we want to add it to the master page. To do this we have one tag that is

    <SharePoint:DelegateControl runat="server" ControlId="" AllowMultipleControls=""/>

    ControlId –> is the Id of the control which we given in the elements.xml file while deploying the file. (Don’t worry at this time. We will cover in how to create delegate control in Visual Studio section)
    This is the main element for delegate control.

    Creating delegate control in Visual Studio
    Now I am creating a small control to enable a link for registering the new user in home page.
    To do this, you have to enable the forms based authentication. If you are not familiar to how to setup forms based authentication for sharepoint 2010 site then visit previous post.

  • After setting up the forms based authentication, open the visual studio and create an empty project.
  • Now add the control templates mapped folder, visual webpart, empty element like below image.
  • Now add the following code to the designer surface of the visual webpart
  • <div id="RegisterUserDiv" runat="server">
     <a href="#">Sample Delegate Control</a>
  • In elements.xml file under the empty element you added, add the following code.
  • <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="">
      <Control Id="RegisterHereControl" Sequence="1000" ControlSrc="~/_controltemplates/RegisterUser.ascx" />
  • Save the changes and deploy into the site.
  • Upto now we created a delegate control and deployed. Now we want to add it to our site. Now add the following code to our master page.
  • <SharePoint:DelegateControl ControlId="RegisterHereControl" AllowMultipleControls="true" runat="server"></SharePoint:DelegateControl>
  • It will look like this.
  • Advertisements

    Published by


    Nothing to say.. lot to hear

    One thought on “Create delegate control in sharepoint”

    1. This is the best ever example of delegate control explanation, very simple and straightforward.
      Nice post, keep it up.


    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s