7.5. Delegate Controls

Chapter 4 presented Features as a way to address the limitation in previous versions of SharePoint of not being able to easily attach new (or replace existing) functionality in SharePoint sites. Microsoft added yet another capability to easily inject custom user controls or server controls into pages for new content or to replace existing content defined by Microsoft in the out-of-the-box site templates or by custom developed templates and pages.

These replaceable areas within pages (master pages, content pages, page layouts, etc.) are implemented using delegate controls. Delegate controls are a special type of server control (<SharePoint:DelegateControl />). Each delegate control has a unique ID, specified using the ControlId attribute. This ID is used to register specific controls (user controls or server controls) using the site element <Control /> within element manifest files in Features. The advantage of using Features is twofold. First, because Features are scoped, a delegate control can be scoped, so the addition/replacement can be as limited as the current site, or as far reaching as the entire SharePoint farm. Second, Features empower site owners to add/replace functionality via Feature activation. When controls are registered via Features, one of the properties that must be set is the order in which to add the control. This is specified using the <Control Sequence="" /> attribute.

How does it work? When a page is requested, the delegate control ...

Get Professional SharePoint® 2007 Web Content Management Development: Building Publishing Sites with Office SharePoint Server 2007 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.