The Sharepoint Delegate Control

Having just gone through with Dave on using an alternative navigation in a master page I thought it useful to post on the Sharepoint Delegate Control.

Andrew Connell has a great explaination on this in his Web Content Book & of course there is some information in the SDK.

The delegate control is a means to inject custom user controls, or server controls into page, or to override the default Microsoft controls. They are identified in pages (master pages, content, page layout or application pages) by the <SharePoint:DelegateControl/> tag.

As an example, <SharePoint:DelegateControl ControlId="MyControl></SharePoint:DelegateControl>

Each tag has a unique ID, specified using the ControlId attribute. A developer can produce a control, wrap it into a feature then in the manifest specify the ControlId in which to place their control. In addition to the ID, the manifest will specify a sequence number. This is an important attribute as explained below.

The sequence number allows a control to override another control - the lowest sequence number will always win. Take for example the following diagram....

In this case 3 features have been activated - Feature A, Feature B and Feature C. All are placing controls into MyControl. Because Feature B has the lowest sequence number, it wil be rendered onto the page at runtime, irrespective of when it was activated. If FEATURE B is deactivated, then FEATURE C will win.

If no controls are placed into the DelegateControl, then at runtime the placeholder will be blank.

Examples of use are the search control. A developer can write a custom search control. the feature will sepcify a ControlId of SmallSearchInputBox and a sequence of 10. Once activated, this will overwrite the existign search controls.

Of course, the beaty of this is that the master page does not have to be modified and the feature can be retracted at any time.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day