Extra, Extra HTML
What about situations where you need to wrap the delegate control in some static HTML? Although it's possible to include HTML around the DelegateControl
, that approach emits the HTML whether the DelegateControl
exists or not. Two attributes—PrefixHtml
—control the HTML to be emitted before the delegate control and the HTML to be emitted after the delegate control, respectively. This technique allows you to add HTML only when a delegate control exists. You’ll find that the out-of-the-box SharePoint templates do this when they want to emit a <div>
tag with a class around content when it appears.
The Scope attribute is another delegate control attribute. While it may appear to be seemingly useless, it does allow you to filter delegate controls to those deployed by features of the same scope. This attribute allows you to make certain delegate controls work throughout the entire farm, not just within a single web site or web application. Farm features are activated automatically when they are installed, allowing the template designer to create points that must be applied everywhere.
The out-of-the-box default.master defines these delegate controls for you to override:
Of these, only the AdditionalPageHead
is set to allow multiple controls. Notice that PublishingConsole
is defined, which is true even if MOSS isn't installed.
Delegate controls are an important option for creating solutions that can be mixed and matched with other options. The ability to isolate one feature on a site from another feature can be an important tool in the SharePoint developer's toolbox.