CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Create own delegate control

In this post I’ll show how to create a simple (but own) delegate control.
A short intro and links on delegate controls can be found on sharepointoverflow.

Take a look on master page. There are already many delegate controls. The delegate control with id AdditionalPageHead can be used for adding your script or jQuery library.:

<SharePoint:DelegateControl 
    runat="server" 
    ControlId="AdditionalPageHead" 
    AllowMultipleControls="true"/>

You can also override existing controls like searchbox. But what if you want to add some content in the master page where no delegate controls are present. Of course, you can add it directly to the master page. Perhaps not on all webs? You can use placeholders to manage it. But do you want to update all the page layouts?

So the solution is to use delegate controls, for adding multiple pieces of content or overriding using Sequence. In this example I’ll add some new content to the quicklaunch bottom area:

<SharePoint:UIVersionedContent 
	UIVersion="4" runat="server" 
	id="PlaceHolderQuickLaunchBottomV4">
	<ContentTemplate>

Now we’ll create a brand new delegate control. Just add it after ContentTemplate:

<SharePoint:DelegateControl runat="server" 
     ControlId="AdditionalQuickLaunchArea" 
     AllowMultipleControls="true"/>

In your Visual Studio project add a mapped folder for CONTROLTEMPLATES and add a new user control: MyText.

Just write some text in the user control.

Add a new empty element:

Reference to your user control in the elements.xml file:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Id="AdditionalQuickLaunchArea" 
           ControlSrc="~/_CONTROLTEMPLATES/MyText.ascx" 
           Sequence="1000" />
</Elements>

Now deploy to your site and see the difference:

This is just a simple tutorial which shows how to start developing a custom delegate control, only for demonstration purpose only. No formatting or good solution design have been payed attention.

Here is the original s4-leftpanel section from v4 without v3 ui versioned controls:

<div id="s4-leftpanel" class="s4-notdlg">
	<div id="s4-leftpanel-content">
		<asp:ContentPlaceHolder id="PlaceHolderLeftNavBarDataSource" runat="server" />
		<asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat="server" />
		<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server"></asp:ContentPlaceHolder>
			<asp:ContentPlaceHolder id="PlaceHolderLeftNavBarTop" runat="server"/>
		<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">
			<div class="ms-quicklaunchouter">
				<div class="ms-quickLaunch">
					<asp:ContentPlaceHolder id="PlaceHolderQuickLaunchTop" runat="server">
					</asp:ContentPlaceHolder>				
	
					<Sharepoint:SPNavigationManager id="QuickLaunchNavigationManager"
						runat="server"
						QuickLaunchControlId="QuickLaunchMenu"
						ContainedControl="QuickLaunch"
						EnableViewState="false"
						CssClass="ms-quicklaunch-navmgr">
						<div>
							<SharePoint:DelegateControl runat="server" ControlId="QuickLaunchDataSource">
								 <Template_Controls>
									<asp:SiteMapDataSource
									SiteMapProvider="SPNavigationProvider"
									ShowStartingNode="False"
									id="QuickLaunchSiteMap"
									StartingNodeUrl="sid:1025"
									runat="server"/>
								</Template_Controls>
							</SharePoint:DelegateControl>

							<SharePoint:UIVersionedContent UIVersion="4" runat="server">
								<ContentTemplate>
									<SharePoint:AspMenu
									  id="V4QuickLaunchMenu"
									  runat="server"
									  EnableViewState="false"
									  DataSourceId="QuickLaunchSiteMap"
									  UseSimpleRendering="true"
									  UseSeparateCss="false"
									  Orientation="Vertical"
									  StaticDisplayLevels="2"
									  MaximumDynamicDisplayLevels="0"
									  SkipLinkText=""
									  CssClass="s4-ql" />
								</ContentTemplate>
							</SharePoint:UIVersionedContent>
						</div>
					</Sharepoint:SPNavigationManager>

					<asp:ContentPlaceHolder id="PlaceHolderQuickLaunchBottom" runat="server">
						<SharePoint:UIVersionedContent UIVersion="4" runat="server" id="PlaceHolderQuickLaunchBottomV4">
							<ContentTemplate>
								<ul class="s4-specialNavLinkList">
									<li>
										<SharePoint:ClusteredSPLinkButton
											runat="server"
											NavigateUrl="~site/_layouts/recyclebin.aspx"
											ImageClass="s4-specialNavIcon"
											ImageUrl="/_layouts/images/fgimg.png"
											ImageWidth=16
											ImageHeight=16
											OffsetX=0
											OffsetY=428
											id="idNavLinkRecycleBin"
											Text="<%$Resources:wss,StsDefault_RecycleBin%>"
											CssClass="s4-rcycl"
											PermissionsString="DeleteListItems" />
									</li>
									<li>
										<SharePoint:ClusteredSPLinkButton
											id="idNavLinkViewAllV4"
											runat="server"
											PermissionsString="ManageLists"
											NavigateUrl="~site/_layouts/viewlsts.aspx"
											ImageClass="s4-specialNavIcon"
											ImageUrl="/_layouts/images/fgimg.png"
											ImageWidth=16
											ImageHeight=16
											OffsetX=0
											OffsetY=0
											Text="<%$Resources:wss,quiklnch_allcontent_short%>"
											accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
									</li>
								</ul>
							</ContentTemplate>
						</SharePoint:UIVersionedContent>
					</asp:ContentPlaceHolder>
				</div>
			</div>
		</asp:ContentPlaceHolder>
	</div>
</div>
Advertisements

4 responses to “Create own delegate control

  1. Pingback: Custom PlaceHolder « Sharepoint. Kunskap. Upptäckter på resan.

  2. Pingback: Contact Site Administrator from anywhere in you SharePoint site. « SC Vinod's Blog

  3. Pingback: SharePoint Delegate Contro « Mir Hassan Shahani

  4. Thakhi 2012-11-04 at 08:55

    You are saying ,no need to modify the master page ,but creating a custom place holder needs to modify the master page.right?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized healthcare services and solution advisory firm.

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points!!

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

%d bloggers like this: