My new blog

My blog has moved to www.davehunter.co.uk/blog see you there.

Friday, 13 July 2007

Hosting UserControls vs Delegate Control

There are two main approaches for adding user controls to your site:

  1. Deploying them to the "wpresources" folder
  2. Using the DelegateControl

Many people have blogged about each technique, but which is the best or the recommended approach?

Tony Rahbun has posted an article called "WebParticles: Developing and Using Web User Controls as WebParts in Microsoft Office SharePoint Server 2007" http://www.codeproject.com/spoint/WebParticles.asp.

Microsoft's recommended approach is to use the DelegateControl. http://msdn2.microsoft.com/en-us/library/ms463169.aspx.

Advantages of using the DelegateControl over hosting UserControls in the wpresources folder

  • Using Solution deployment in SharePoint 2007 you can create a WSP to automate the deployment of your UserControls (stored in the ControlTemplates folder) and Features (used to activate a DelegateControl).
  • You can control the scope of the feature.
  • More closely integrated with SharePoint.
  • If the feature isn't activated the DelegateControl will fall over gracefully. This would enable the component to be hidden if no longer needed.

No comments: