Monthly Archives: December 2008

Delegate Controls – Why you need to delegate!

I wanted to introduce this topic before my break for the festive season, as I am going to be offline pretty much until a few weeks into 2009. And this topic is around the subject of Delegate Controls!

What are Delegate Controls?
Well .. delegates are basically a new control that can be used in SharePoint (both WSS 3.0 and MOSS 2007) which allow you to render different controls on different sites, using features to switch them on and off.

Sound interesting? Well let me whet your appetite further.

Apart from the fact that you can create your own delegates (hopefully your dev brain boggles already!) but Delegates are already in use in a large number of places in SharePoint:

  • Top Navigation Menu Control
  • Quick Launch Menu Control
  • Search Controls
  • My Links / Quick Links controls
  • etc …

So .. in short, if you want to modify these controls you don’t need to modify the master page.
I’ll say that again, just in case you missed it. You don’t need to modify the master page.

The delegate controls are already in the default.master, so you just need to install and activate a feature which tells SharePoint to use your custom control instead of the standard ones!

Neat huh? (I knew you’d like it)

So what kind of controls can I use with Delegates?
You’ll like this answer too …. anything.

Yep, any control (either ASCX based user controls, or DLL based server controls) can be dropped into a delegate. All you need is a feature that registers it!

So how does it all work then?
Well .. delegates have 2 parts to them:

  • ASP.Net Delegate Control (effectively a placeholder)
  • Feature which registers a new ASP.Net control to use in place of the delegate

The structure of a Delegate Control is very simple:

<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />

You only have 1 attribute to worry about; ControlId is basically a unique "name" for your placeholder. The example shown here is for the standard Search control that appears on every page.

After you’ve got your Delegate Control, you need a feature to implement your actual ASP.Net controls. Luckily the feature is quite straightforward.

Example using Server Control
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="">
        ControlAssembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
            <Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
            <Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif</Property>
            <Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>
            <Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>
            <Property Name="UseSiteDefaults">true</Property>
            <Property Name="FrameType">None</Property>
            <Property Name="ShowAdvancedSearch">true</Property>
Example using User Control
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns=""> 
    <Control Id="CentralAdminLeftNavBarTop" Sequence="100" ControlSrc="~/_admin/configurationmonitor.ascx" />

The Id is the same as your "ControlId" property in your Delegate control. Then you either reference a set of Control Class / Control Assembly, or you point it to a relative path to the ASCX control using the ControlSrc property.

Thats it! Once your feature is activated (at whatever scope you choose … Farm, Application, Site, Web) then your ASP.Net control will appear in place of the delegate!

But what about Sequence??
Ahhh … well that is where the real beauty of Delegates comes through in a SharePoint environment! As the controls are installed and activated using Features, how do you account for having multiple features at multiple scopes?

The Sequence attribute allows you to offer a number value which will be used when choosing which feature has priority. Simply put, the feature with the lowest sequence number will be rendered.

This allows you to achieve 2 different things:

  1. Upgrade Path
  2. Different controls on different sites

In the example of an Upgrade path, take the example of the "SmallSearchInputBox" ControlId.

In WSS 3.0 this is implemented through a feature with a Sequence of 100. In MOSS 2007 Standard a replacement control was installed with a Sequence of 50. And in MOSS 2007 Enterprise another new control is implemented with a Sequence of 25!

Hopefully you can see the picture, but I’ll join the dots anyway!

The same delegate, and the same master page is used in all 3 installs. But as you install a newer version, a replacement feature is activated (with a lower sequence number) which takes preference.

So .. if you wanted to replace the "SmallSearchInputBox" control in a WSS 3.0 system, but wanted the "out of the box" control to come back if they ever install MOSS 2007, then you could register your own feature with a Sequence of anything between 100 and 50.

This same approach can be used if you wanted to replace controls on a specific site. So lets say you want to replace the Quick Launch navigation control in specific web sites. You could create a Web scoped feature, and activate it on those sites that you want to replace the Quick Launch in.

No Master Page, No ASP.Net Web Form dev … easy.

Joining Content & Code as a Solutions Architect! (on Monday)

Ok .. so here is another reason why my posts have been few & far between recently .. yep … I’m moving on to pastures new, and Friday is my last day at Ratio One!

Thankfully I have not succumb to the dreaded "credit crunch" but have decided to take a fantastic opportunity to join the Solutions Team at Content & Code as one of their Solution Architects, helping to design and scope solutions, aiding the consultants and developers in their technical delivery, drive best practice in the business and also try to get more involved in the SharePoint Community.

What does this mean? Well, I will still be making the same blog posts, and be just as active on the MSDN forums (if not more so!). It also means you’ll be seeing a bit more of me at the User Groups and community events around London (and possibly elsewhere in Europe?).

I would also like to take this opportunity to both thank Content & Code for this great opportunity, and also to thank Ratio One for their support over the past 2 (and a bit) years. I’ve certainly come on a long way since my first forays into SharePoint, and (generally) loved every minute of it!

Creating “External” URLs in the Quick Launch menu

This post was prompted by the problems I’ve been having trying to get header nodes to be added to a site when it is provisioned, which have a custom URL pointing at a different site in the site collection.

Despite the NavBar element in the onet.xml having a URL attribute, this had no effect on my quick launch and it was always created using the current web’s URL (i.e. on click it just took me straight to the current web site home page).

So, I embarked on a simple feature which I could use to create those navigation headers.

The code is pretty simple:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
            // get the current "Web" object
            using (SPWeb web = (SPWeb)properties.Feature.Parent)
                    // create the new navigation node
                    SPNavigationNode newNode =
                        new SPNavigationNode("Go to any sub site", "/anysite/anysubsite", true);

                    // add the node to the quicklaunch menu

                    // save the changes

Now, the main thing to note is that when you create your SPNavigationNode object to use the true argument in the constructor!

This tells SharePoint that the URL is an External URL (and by External .. I mean "not in the current web"). If you don’t set this then you will get an error telling you that the URL is invalid, or that the page/file cannot be found.

Even if the URL is a relative URL to the same site collection, you still have to set this value to true! Not entirely obvious that one, so one to watch out for.

Sad news …

Sorry that my activity in the past week has been a bit poor … but my mother-in-law died last week. I’ve basically been buried in the subsequent activities (funeral directors, coroner, registrar, church, etc) which was made much harder because my father-in-law is deaf and cannot use the telephone.

Funeral on Thursday .. hopefully be back to my old self by the weekend.

New (Old) Car !!

Yay … I just bought me a new (old) car ..
Been needing a second car for a while (the Mrs always nicks my main car to drive to work everyday) and been needing a run-about to take rubbish to the tip and to get me to the train station and back 🙂

So .. got myself a nice little Ford Fiesta .. 1.3 engine, ABS, Power Steering, new CD player … and only 70,000 miles on the clock (despite being over 10 years old). Not bad for only £700 (at least I think so). Very pleased with it 🙂

Adding FAVICONS to SharePoint

Ok .. I admit it .. this isn’t really just a SharePoint thing, it’s a "web" thing, but quite frankly I am astounded that this isn’t something provided out of the box.

So what are these favicon things anyway?

Favicons are the icons that appear in your web browser when you are surfing. They usually appear in the address bar (depending on your browser) and were originally created for older IE environments to help identify web sites in the Favourites folder (hence the name "favicon" = "favourites icon").

example favicons

Ok, thats great, so how do I get them in SharePoint?

Well, it’s really quite simple. Favicons are represented by small "link" tags in your HTML. In SharePoint the most sensible place to put them is in the Master Page. The reason for this is that (generally) your Master Page is rendered for pretty much every page .. therefore you don’t have to add favicon links all over the place.

All you need to do is put a "link" tag into your Master Page, within the "<head>" tags (i.e. it needs to be in the page header!)

<link rel="shortcut icon" href="/Portal Images/favicon.jpg" />

How to "SharePoint’ise" it!

I know, that’s not a real word, but the best approach you can take is to place your icon image (either an icon or image file) into an Image Library. You can then place a relative URL to a specific image in that image library, and it allows the content editors to upload a new favicon whenever they want 🙂 (with the same version control and content approval you would normally have).

Thats exactly what I did with the sample line of code above, with a file called "favicon.jpg" which is located in an Image Library called "Portal Images" at the top level of the site collection.

Now, if you want to get REALLY fancy, then you could change it to be relative to the Site Collection (so each site collection could potentially have a different favicon). Do you that, just follow my earlier post on creating "Site Collection Relative URLs in MOSS 2007".

Neat eh?

Word, Excel and PowerPoint running from the browser .. it must be Office 14 for Web

This is a great "first look" video from Channel9 ( showing off the new browser based features of the Office 14 for web (still in beta, still in development!) at this weeks PDC!

It’s hot off the press, and it’s going to blow your socks off!

According to the video they have made heavy use of Silverlight and AJAX to create rich office clients that run through a web browser. Due to the user of Silverlight the rendering is crisp and detailed, and to be honest I couldn’t tell the difference between the web version and the desktop client!

Multi-User editing (including from the browser!) allowing multiple users to edit the same document at the same time is demo’d, including talk about integrating better collaboration tools!

To get you even more excited, the web browser based application is demo’d from FireFox! That’s right, the new Office 14 apps are being designed with complete and total cross-browser compatibility.

Excited about the next version of Office?? (i.e. SharePoint!!!) I am!

Blank “Web File Properties” when saving document from Word 2003

This is a problem that I encountered with a MOSS 2007 system that was upgraded from SPS 2003.

Specifically, we were developing a custom document library, and found that if we had libraries with multiple content types, when we tried to save documents from Microsoft Word 2003 the "Web File Properties" dialog (the pop-up window that asks you for metadata before the file hits the document library) was completely empty.

None of the fields were visible, not even the Content Type drop-down box!

Well, It seems that this problem is documented and known about, and there is a Microsoft Hotfix available (upon request).

(KB934253) The Web File Properties dialog box displays incorrect properties for a document that is saved in a Windows SharePoint Services 3.0 document library –;EN-US;934253

The solution to the issue above has been included in to a hotfix, which you can get the information from the following KB article:

(KB934790) Description of the Windows SharePoint Services 3.0 hotfix package: April 12, 2007 –;EN-US;934790

*files this one away for later*

Medals in the MSDN Forums .. what do they mean?

If you are a regular user of the MSDN Forums then you may (or may not?) that each user is granted a number of "medals" (they used to be stars, for the old timers).
Well, I’ve taken a sneak peak through the members list, and deduced that medals = points.
Exactly how many points you have depend on a lot of things, including posts, answers, "helpful" tags and how "popular" your threads are.
I have got the following list though:
  • 0 Medals – 0 points (1 or 2 posts)
  • 1 Medal – 10 points (usually 1-5 posts)
  • 2 Medals – 750 points (roughly 30 "answers")
  • 3 Medals – 2,000 points (roughly 150 "answers")
  • 4 Medals – 7,500 points (roughly 300 – 500 answers)
  • 5 Medals – 50,000 points (roughly 1000 answers)

To find your own account (and how many "points" you have) you can use the search page.

Number of certified SharePoint Developers increase by 500% in 12 months …

So demand slowly catches up with the market. Despite the credit crunch, and supposed "global economic recession", the SharePoint markets (and IT in general) continue to buck the trend.
There are now 2,360 MCTS WSS 3.0 Application Developers in the world. Last time I checked (about this time last year) there was less than 450! Not bad growth, I think.
« Older Entries