using delegate controls in sharepoint

Post on 22-May-2015

6.110 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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!

TRANSCRIPT

DELEGATE CONTROLS - WHAT, WHERE & HOW

Shai PetelMCTS, MCT

VP R&D – KWizComshai@kwizcom.com

KWizCom Business Card• Founded in 2005• Headquartered in Toronto• Global provider of add-ons and services• 3000+ customers worldwide

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.

Fields of expertise:

• Microsoft Office SharePoint

• Microsoft Dynamics CRM

Competencies:

Gold Certified Partner• ISV• Information Worker

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?

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)

Customize SharePoint pagesWeb parts

Customize SharePoint pagesMaster / Layout Pages

Master pages, Page Layouts• Advantages

Easily define pages design structure (and base content) Provide templates which enables easy changing 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

Customize SharePoint pagesMaster / Layout Pages

Customize SharePoint pagesMaster / Layout Pages

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!

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 master pageCan be overridden by other features with higher priority (lower value) unintentionally

Where can I find Delegate Controls?

Delegate controls in default.master: • AdditionalPageHead (Allows multiple controls!)• GlobalSiteLink0, GlobalSiteLink1,

GlobalSiteLink2 • SmallSearchInputBox • TopNavigationDataSource • PublishingConsole • QuickLaunchDataSource

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

Examples of build in controlsCustom logic!

Examples of build in controlsCustom logic!

Examples of build in controlsFeature logic!

How do I start working with Delegate Controls?

Its as easy as 1,2,3!• Add a delegate control to your page• Create a candidate control• Register your candidate to the delegate

using a feature!

Delegate ControlDeclaration on page / master

Registering a new 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. 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.

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>

So, Why should I use it?

Now you can:• 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)

• Implement a master page that behaves differently in different sites, based on features.

Questions

Questions before live demo?

HANDS-ON EXAMPLES

Live demo:• Feature that registers delegate control• Activating / Deactivating

It all comes together...

Branding

• Master Pages• Layout Pages

Content

• Web Parts• User Controls• Content Place

Holders• Delegate Controls

Styling

• CSS• Images

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

Questions

top related