WebControl

ShUIE is based around the idea that if we can get custom pieces of JavaScript and CSS onto a page, then we have very few limits as to what we can do inside SharePoint. To enable use to get JavaScript and CSS onto a page, we use a WebControl. This page is simply to describe how that works.

The WebControl is a bog standard WebControl, nothing special about it... what is special is a feature of the SharePoint MasterPage template.

In the top of the MasterPage template:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master

There is this code around line 21:
<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

What this says is that if you register a WebControl under the Id of AdditionalPageHead, then it will render that control at this point.

The AllowMultipleControls statement means that many controls with that Id can be rendered.

So... by declaring our WebControl with that Id, we have a supported way of rendering anything we want within the head of the document.

Upsides:
  • Supported by Microsoft.
  • Correct place to put JavaScript and CSS is in the head.
  • Will not conflict with any other control registered for rendering at that point.

Downsides:
  • Because the AdditionalPageHead occurs very early, we cannot use RegisterPageScript to include WebControl resources, we have to do it manually.
  • If the SharePoint site is based off of a custom master page that does not include that code, ShUIE will not function.

Last edited Dec 4, 2008 at 12:42 PM by DavidK, version 1

Comments

No comments yet.