Friday, June 03, 2011

SharePoint 2010 Delegate Control

SharePoint 2010 Delegate Control

This control delegates asp.net control to render inside its template.
In your home page of the sharepoint site you can see the "MySite,Search Input box with lens icon and "Global Navigation".
These controls are called "Delegate Controls".You can create new asp.net web controls or user control and put
them inside the delegate template.Your customised user control will be render as per your sequence specified in
"Element.xml" of the sharepoint project solution.
If you want host multiple user controls in "Delegate template" then set the property of the Control "AllowMultipleControls" to true.
This will allow the delegate control consider as "Child control" as per the sequence.
The Lower sequence will always replace the highest sequence in rendering mode.
If you create the user control refer the controlSrc[usually it will be the virtual directory of ControlTemplate(_controltemplates) ]properties of "Control" in Element.xml
My Element.xml belows like.


  


on my UserControl's on Click of the Button events I just simply placed an javascript alert.
this.Page.ClientScript.RegisterClientScriptBlock(Page.GetType(),"Greetings", "Type your script");
You can set scope on your "Feature File"