Delegate Controls: What, Where and How
-
Upload
shai-petel -
Category
Technology
-
view
1.909 -
download
2
description
Transcript of Delegate Controls: What, Where and How
![Page 2: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/2.jpg)
Topics
• 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?
![Page 3: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/3.jpg)
Customize SharePoint pagesWeb parts
SharePoint 101… Add web parts• Advantages
Done in run-time by non-technical content manager Flexible and customizable by user via web part properties
• LimitationPer-page operation (add, modify, remove)Cannot change page structure, only add/remove web partsCannot moderate options (allow/deny only)
![Page 4: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/4.jpg)
Customize SharePoint pagesWeb parts
![Page 5: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/5.jpg)
Customize SharePoint pagesMaster / Layout Pages
Master pages, Page Layouts• Advantages
Easily define pages design structure (and base content) Provide templates which enables easy switching Limit choices to several approved predefined option
• LimitationStatic set of templatesCannot target content based on logic, need to manually develop logic or create several master / layout pages
![Page 6: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/6.jpg)
Customize SharePoint pagesMaster / Layout Pages
![Page 7: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/7.jpg)
Customize SharePoint pagesMaster / Layout Pages
![Page 8: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/8.jpg)
What is a Delegate Control
A Delegate Control is:• Another level of encapsulation• Control “place holder”• Enables run-time binding between a page and
actual hosted controls• Built in support for logic – loading based on
features• Enables making changes in your provisioned
sites without having to recode your site pages!
![Page 9: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/9.jpg)
Why use Delegate Controls?
Delegate Controls• Advantages
Support logic for loading controls Automatic deploy to specific scope (Farm, Web Application, Site
Collection, Web Site) Control will unregister once it’s feature is deactivated
• LimitationOnly targets a pre-defined place holder in the pageCan be overridden by other features with higher priority (lower value) unintentionally*
![Page 10: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/10.jpg)
Where can I find Delegate Controls?
Delegate controls in default.master: • AdditionalPageHead (Allows multiple controls!)• GlobalSiteLink0, GlobalSiteLink1,
GlobalSiteLink2 • SmallSearchInputBox • TopNavigationDataSource • PublishingConsole • QuickLaunchDataSource
![Page 11: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/11.jpg)
Delegate Controls in FeaturesFeature File Control ID PriorityGradualUpgrade SharedServicesControl.xml TargetWebApplicationAdditionalSettings 50LocalSiteDirectoryControl SiteControlPanel.xml CreateSitePanel1 100MasterSiteDirectoryControl SiteCollectionControlPanel.xml CreateSiteCollectionPanel1 100MySite MySiteFeatureElements.xml GlobalSiteLink1 100MySite MySiteFeatureElements.xml GlobalSiteLink2 100MySite MySiteFeatureElements.xml ProfileRedirection 100MySiteNavigation MySiteNavigationFeatureElements.xmlTopNavigationDataSource 25MySiteQuickLaunch MySiteQuickLaunchFeatureElements.xmlQuickLaunchDataSource 25OSearchBasicFeature SearchArea.xml SmallSearchInputBox 50OSearchEnhancedFeature SearchArea.xml SmallSearchInputBox 25OsrvLinks serverroleselector.xml QuickLaunchDataSource 25OsrvLinks serverroleselector.xml ServicesOnServerRoleControl 100OsrvLinks serverroleselector.xml CentralAdminLeftNavBarTop 100OssNavigation navigationelements.xml QuickLaunchDataSource 25Publishing EditingMenu.xml PublishingActionMenu 50Publishing EditingMenu.xml PublishingConsole 50Publishing VariationsFlagControl.xml GlobalSiteLink0 50Publishing VariationsFlagControl.xml VariationsFlagControl 50
![Page 12: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/12.jpg)
Examples of build in controlsCustom logic!
![Page 13: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/13.jpg)
Examples of build in controlsCustom logic!
![Page 14: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/14.jpg)
Examples of build in controlsFeature logic!
![Page 15: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/15.jpg)
How do I start working with Delegate Controls?
Its as easy as 1,2,3!1. Add a delegate control to your page2. Create a candidate control3. Register your candidate to the delegate
using a feature!
![Page 16: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/16.jpg)
Delegate ControlDeclaration on page / master
Registering a new delegate control named “MyTargetedControl” :
<SharePoint:DelegateControl runat="server“ ControlId="MyTargetedControl" Scope="Site Collection" AllowMultipleControls="false"/>
• Note: The scope attribute indicates where SharePoint will look for possible candidates. If specified, it must match the scope of the feature registering the controls
• 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.
![Page 17: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/17.jpg)
Delegate ControlRegistration Via feature
Registering a user control:<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="MyTargetedControl" Sequence="90" ControlSrc="~/_ControlTemplates/SayHello.ascx">
<Property Name="ImageSrc">/_layouts/images/gosearch.gif</Property></Control>
</Elements>
Registering a custom control:<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="MyTargetedControl " Sequence="80"ControlClass= "Company.Product.ControlClass" ControlAssembly= "Company.Product, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX">
<Property Name="ImageSrc">/_layouts/images/gosearch.gif</Property></Control>
</Elements>
![Page 18: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/18.jpg)
So, Why should I use it?
Now you can:• Easily override existing SharePoint controls
without any need to update provisioned sites/pages!
• Implement a master page that behaves differently in different sites, based on features.
![Page 19: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/19.jpg)
So, Why should I use it?
Usage examples:• Register CSS or JS file to all pages within scope• Add SEO page header tags• Replace SharePoint search box• Change top/context navigation data source
based on some other logic (while using the same shared master page)
![Page 20: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/20.jpg)
Questions
Questions before live demo?
![Page 21: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/21.jpg)
HANDS-ON EXAMPLES
Live demo:• Feature that registers delegate control• Activating / Deactivating
ImageControlCandidate.zip
![Page 22: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/22.jpg)
New in 2010
• In SharePoint 2010 – Injecting JS files can be done directly form your feature!
![Page 23: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/23.jpg)
It all comes together...
Branding
• Master P
ages
• Layout Pages
Content
• Web Parts
• User Contro
ls
• Field contro
ls
• Delegate
Controls
Styling• CSS
• Images
![Page 24: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/24.jpg)
More information online
• Delegate Control description http://msdn.microsoft.com/en-us/library/ms463169.aspx
• How to: Customize a Delegate Control http://msdn.microsoft.com/en-us/library/ms470880.aspx
![Page 25: Delegate Controls: What, Where and How](https://reader036.fdocuments.in/reader036/viewer/2022062616/549a65d9b4795971668b4597/html5/thumbnails/25.jpg)
Questions