What is Delegate Control?

Definition: Delegate Control is a custom functionality/control that can be placed in place of particular SharePoint functionality/control.

Some Points:

  1. We don’t need to change the existing functionality
  2. We don’t need to change the master page.
  3. We are creating our own functionality and replacing it with existing SharePoint functionality.

Delegate controls provided in SharePoint 2010:

  1. AdditionalPageHead: You can use this to inject scripts (JS, CSS, etc..) in the master page HTML Head Tags.
  2. GlobalNavigation: Top most control collection visible on page.
  3. GlobalSiteLink3: This delegate control is for two icons on the site. (1) I Like It (2) Tags & Notes
  4. GlobalDelegate2: SharePoint dashboard control
  5. GlobalDelegate0: You can change the top right section/menu. You can remove this space or add some more links to it.
  6. PublishingConsole: Server-side code for ribbon control is loaded using this delegate control. You can add you server actions in this control.
  7. TopNavigationDataSource: This control is for top navigation data source. You can use this control to change the default data source and load your own.
  8. SmallSearchInputBox: This control is for default small search box you see on the page.
  9. QuickLaunchDataSource: This control is for the data source of the left-hand side links panel. You can customize this to pass your own data source.
  10. TreeViewAndDataSource: This is different navigation other than quick launch and top navigation. You can pass your own data source here and render links accordingly.

 Delegate controls provided in SharePoint 2013:

  1. SuiteLinksDelegate: Delegate control to handle links (1) Newsfeed (2) SkyDrive (3) Sites. You can add your own link also.
  2. SuiteBarBrandingDelegate: This control is for top left side site logo and text.
  3. PromotedActions: This control is for empty space between SHARE and FOLLOW link on top right corner

How to use:

  1. To create new Delegate Control, we need to create a package using Visual Studio
  2. Go to Visual Studio >> New SharePoint Project >> Farm solution.
  3. Create user control and place your content/code in this user control. OOB control will be replaced by the content of this user control.
  4. Now we need to register the control using Feature element.
  5. We need to specify the control to use, Sequence Number and URL to the control or assembly as described below, in Feature element file.

<?xml version=""1.0"" encoding=""utf-8"" ?>

<Elements xmlns=""http://schemas.microsoft.com/sharepoint/"">

  <Control

            Id=""SmallSearchInputBox""

ControlClass=""Namespace of the control class""

ControlAssembly=""Fully qualified assembly name""

            Sequence=""100""                                                                  

            ControlSrc =""/templates/NewSearchcontrol.ascx""/>

</Elements>

Below are the parameters,

  • Id=""SmallSearchInputBox"": This is Delegate Control name you want to replace with your control.
  • ControlClass: (Optional) Namespace of the control class
  • ControlAssembly: (Optional) Fully qualified assembly name
  • Sequence=""100"": Type is Integer. Used for sequence number for the control. Control with the lowest sequence number is added to the tree.
  • ControlSrc: Relative URL of the .ascx file, that is control file
  1. We are done. Now, Build >> Deploy and activate the feature.
  2. You will be able to see that OOB control is replaced by the custom control.
© 2019 Code SharePoint