[SharePoint 2010 – Developpement] Create User Control in SharePoint 2010 MasterPage

Today we need to create a user control that modify SharePoint Logo behaviour :
-We want to redirect the user to a site if the user is in a subsite

Procedure :

Add a UserControl in your SharePoint Visual Studio project

  1. Create a new element in visual studio, it will create files in ControlTemplates

image
Deploy the project
Go to “C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATECONTROLTEMPLATES” in order to see the full link of your userControl that you are gonna use in the next step
Reference your UserControl in the masterPage thanks to, and adapt the link :

   1: <%@ Register Src="~/_controltemplates/yourprojectName/Logos.ascx" TagName="Logos" TagPrefix="uc1" %> 

Reference the userControl in the masterPAge :

   1: <uc1:Logos id="Logos1" runat="server"> </uc1:Logos >        

Code the user control thanks to the .cs

How to debug a user control :

It’s possible to debug the user control, by attaching all Sharepoint Processus (see CKSDev Extension for visual studio)

image

Advertisements

2 thoughts on “[SharePoint 2010 – Developpement] Create User Control in SharePoint 2010 MasterPage

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