0
ShaiPetel<br />MCTS, MCT<br />VP R&D – KWizCom<br />shai@kwizcom.com<br />Delegate Controls - What, Where & How<br />
KWizCom Business Card<br /><ul><li>Founded in 2005
Headquartered in Toronto
Global provider of add-ons and services
3000+ customers worldwide </li></ul>Business Target:Deliver innovative and cost-effective add-ons, enabling customers to d...
Microsoft Dynamics CRM</li></ul>Competencies:<br />Gold Certified Partner<br /><ul><li>ISV
Information Worker</li></li></ul><li>Topics<br /><ul><li>Review different SharePoint pages customization options
What’s a “Delegate Control”?
Why should I use it?
Where can I find them?
How do I start working with Delegate Controls?</li></li></ul><li>Customize SharePoint pagesWeb parts<br />SharePoint 101… ...
Done in run-time by non-technical content manager
Flexible and customizable by user via web part properties
Limitation</li></ul>Per-page operation (add, modify, remove)<br />Cannot change page structure, only add/remove web parts<...
Customize SharePoint pagesWeb parts<br />
Customize SharePoint pagesMaster / Layout Pages<br />Master pages, Page Layouts<br /><ul><li>Advantages
Easily define pages design structure (and base content)
Provide templates which enables easy changing
Limit choices to several approved predefined option
Limitation</li></ul>Static set of templates<br />Cannot target content based on logic, need to manually develop logic or c...
Customize SharePoint pagesMaster / Layout Pages<br />
Customize SharePoint pagesMaster / Layout Pages<br />
What is a Delegate Control<br />A Delegate Control is:<br /><ul><li>Another level of encapsulation
Control “place holder”
Upcoming SlideShare
Loading in...5
×

Using Delegate Controls In SharePoint

6,162

Published on

The why, where and how of delegate controls for SharePoint.
KWizCom's VP R&D Shai Peltel gave this presentation during SharePoint Saturday Toronto. Go to: http://kwizcom.blogspot.com/ to download this presentation and a free code example!

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,162
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
34
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Introduction,Hi, My name is X I am Y at KWizCom.As an ISV, the nature of our work is to focus on easy deployment of our solutions at the customer’s end.When we want to extend a feature of SharePoint most of the time our customers just run an installer and our product should fit in their environment with as little customization as possible.This is why we need to take advantage of every possible integration option we can get our hands on.Today we are going to talk about one of the less common of these options – Delegate controls.
  • If you been around SharePoint long enough, the first thing you did is play with some web parts.They allow you to add web components to your pages in run time, without a need for coding or designing your pages.You can customize them via web part properties, and even add web part connections for more advanced results.Some of the limitation are that everything must be done in a page level.Also – you can only add web parts where you have web part zones, so the page structure cannot be modified – sometimes we want that important capability, if we do not wish our content editors to break our UI design and basic page structure.Speaking of which, content editors can be given edit pages permissions. you cannot control the web parts they can add, their configuration, connections etc.
  • Advantage: Content editor can choose from limited options thus cannot break the site’s design concept / integrity. Important for WCM public sites.What does “Static templates” mean?if I want to change the content (replace controls/ change properties of controls) I must update the .aspx page.If I want to change the page’s behaviour according to site for example, I will have to deploy different master page/layout per-site or develop a “smart” control that identifies the current site and changes it behaviour accordingly (according to my custom logic: static list of url’s, features, site name etc. – Not ideal)
  • Change master pages
  • Change layouts
  • Another level of page content customization, like web parts, master and layout pages.It is basically a control place holder that allows you to change it’s content based on a feature logic.So you will be able to use the same master page and layout page and still change the page content based on specific logic – feature – without having to code or modify any of these page.
  • So, going back to our advantages / limitation slide we can see that using a delegate control allows us to support some sort of logic in the controls we want to add, to a specific scope. The control will be registered AND unregistered automatically based on the feature The problem here is that you have to target existing place holder controls – delegate controls – that are already in the page. You can target one of SharePoint’s OOB delegate control or create your own.Say you wish to add a link to your project management system, and you want that link to only appear inside project web sites. You could create a delegate control called “ExternalSystemLink” and create a feature that registers “Link to project Mgmt System” only within project sites.This way, in the future you will be able to do the same withing support sites, sales sites and all based on feature logic instead of hand coding everything into the link control itself.Another issue is that the delegate control usually only loads the highest priority (lowest value) control and another control may override your control without you knowing about it.
  • Change layouts
  • Change layouts
  • Change layouts
  • Scope – optional. Limit the search for controls in features at the same scope only.Farm, Web Application, Site Collection, Web Site.AllowMultipleControls – optional.
  • Loading Logic will be separated from the controlsYou can have a generic navigation control, search control that are not aware to your custom loading logicCentralize your loading logic in one place: Feature, or a settings page.
  • Transcript of "Using Delegate Controls In SharePoint"

    1. 1. ShaiPetel<br />MCTS, MCT<br />VP R&D – KWizCom<br />shai@kwizcom.com<br />Delegate Controls - What, Where & How<br />
    2. 2. KWizCom Business Card<br /><ul><li>Founded in 2005
    3. 3. Headquartered in Toronto
    4. 4. Global provider of add-ons and services
    5. 5. 3000+ customers worldwide </li></ul>Business Target:Deliver innovative and cost-effective add-ons, enabling customers to deploy excellent Microsoft SharePoint, Dynamics CRM and Project server solutions, faster than ever and at no risk.<br />Fields of expertise:<br /><ul><li>Microsoft Office SharePoint
    6. 6. Microsoft Dynamics CRM</li></ul>Competencies:<br />Gold Certified Partner<br /><ul><li>ISV
    7. 7. Information Worker</li></li></ul><li>Topics<br /><ul><li>Review different SharePoint pages customization options
    8. 8. What’s a “Delegate Control”?
    9. 9. Why should I use it?
    10. 10. Where can I find them?
    11. 11. How do I start working with Delegate Controls?</li></li></ul><li>Customize SharePoint pagesWeb parts<br />SharePoint 101… Add web parts<br /><ul><li>Advantages
    12. 12. Done in run-time by non-technical content manager
    13. 13. Flexible and customizable by user via web part properties
    14. 14. Limitation</li></ul>Per-page operation (add, modify, remove)<br />Cannot change page structure, only add/remove web parts<br />Cannot moderate options (allow/deny only)<br />
    15. 15. Customize SharePoint pagesWeb parts<br />
    16. 16. Customize SharePoint pagesMaster / Layout Pages<br />Master pages, Page Layouts<br /><ul><li>Advantages
    17. 17. Easily define pages design structure (and base content)
    18. 18. Provide templates which enables easy changing
    19. 19. Limit choices to several approved predefined option
    20. 20. Limitation</li></ul>Static set of templates<br />Cannot target content based on logic, need to manually develop logic or create several master / layout pages<br />
    21. 21. Customize SharePoint pagesMaster / Layout Pages<br />
    22. 22. Customize SharePoint pagesMaster / Layout Pages<br />
    23. 23. What is a Delegate Control<br />A Delegate Control is:<br /><ul><li>Another level of encapsulation
    24. 24. Control “place holder”
    25. 25. Enables run-time binding between a page and actual hosted controls
    26. 26. Built in support for logic – loading based on features
    27. 27. Enables making changes in your provisioned sites without having to recode your site pages!</li></li></ul><li>Why use Delegate Controls?<br />Delegate Controls<br /><ul><li>Advantages
    28. 28. Support logic for loading controls
    29. 29. Automatic deploy to specific scope (Farm, Web Application, Site Collection, Web Site)
    30. 30. Control will unregister once it’s feature is deactivated
    31. 31. Limitation</li></ul>Only targets a pre-defined place holder in the master page<br />Can be overridden by other features with higher priority (lower value) unintentionally<br />
    32. 32. Where can I find Delegate Controls?<br />Delegate controls in default.master: <br />AdditionalPageHead (Allows multiple controls!)<br />GlobalSiteLink0, GlobalSiteLink1, GlobalSiteLink2 <br />SmallSearchInputBox<br />TopNavigationDataSource<br />PublishingConsole<br />QuickLaunchDataSource<br />
    33. 33. Delegate Controls in Features<br />
    34. 34. Examples of build in controlsCustom logic!<br />
    35. 35. Examples of build in controlsCustom logic!<br />
    36. 36. Examples of build in controlsFeature logic!<br />
    37. 37. How do I start working with Delegate Controls?<br />Its as easy as 1,2,3!<br />Add a delegate control to your page<br />Create a candidate control<br />Register your candidate to the delegate using a feature!<br />
    38. 38. Delegate ControlDeclaration on page / master<br />Registering a new control named “MyTargetedControl” :<br />&lt;SharePoint:DelegateControlrunat=&quot;server“ ControlId=&quot;MyTargetedControl&quot; Scope=&quot;Site Collection&quot; AllowMultipleControls=&quot;false&quot;/&gt;<br />Note: The scope attribute indicates where SharePoint will look for possible candidates. It must match the scope of the feature registering the controls<br />Note: Setting the AllowMultipleControls property to true causes all matching candidate controls to be added to the page as children of the delegate control according to the order specified by the Sequence attribute.<br />
    39. 39. Delegate ControlRegistration Via feature<br />Registering a user control:<br />&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;<br /> &lt;Control Id=&quot;MyTargetedControl&quot; Sequence=&quot;90&quot; ControlSrc=&quot;~/_ControlTemplates/SayHello.ascx&quot;&gt;<br /> &lt;Property Name=&quot;ImageSrc&quot;&gt;/_layouts/images/gosearch.gif&lt;/Property&gt;<br /> &lt;/Control&gt;<br />&lt;/Elements&gt;<br />Registering a custom control:<br />&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;<br /> &lt;Control Id=&quot;MyTargetedControl &quot; Sequence=&quot;80&quot;<br />ControlClass= &quot;Company.Product.ControlClass&quot; ControlAssembly= &quot;Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX&quot;&gt;<br /> &lt;Property Name=&quot;ImageSrc&quot;&gt;/_layouts/images/gosearch.gif&lt;/Property&gt;<br /> &lt;/Control&gt;<br />&lt;/Elements&gt; <br />
    40. 40. So, Why should I use it?<br />Now you can:<br /><ul><li>Easily override existing SharePoint controls without any need to update provisioned sites/pages!(Example: replace SharePoint’s search box with your own custom search box)
    41. 41. Implement a master page that behaves differently in different sites, based on features.</li></li></ul><li>Questions<br />Questions before live demo?<br />
    42. 42. Hands-on examples<br />Live demo:<br /><ul><li> Feature that registers delegate control
    43. 43. Activating / Deactivating</li></li></ul><li>It all comes together...<br />
    44. 44. More information online<br />Delegate Control description http://msdn.microsoft.com/en-us/library/ms463169.aspx<br />How to: Customize a Delegate Control http://msdn.microsoft.com/en-us/library/ms470880.aspx<br />
    45. 45. Questions<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×