Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have some custom user control developed. I want to place it in a custom page layout. So it will be in every page instance of that layout. How can i put my custom user control on custom page layout?

Thanks

share|improve this question

2 Answers 2

up vote 6 down vote accepted

First create your User Control and publish is to SharePoint.
Then you register a tag for your control

<%@ Register Tagprefix="MyControls" 
    Namespace="KM.MyControls.MyControl" 
    Assembly="KM.MyControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<Your token>" %>

Then you can reference your User Control

<MyControls:MyUserControl runat="server"/>
share|improve this answer

Make sure you put the user control into a subdirectory of {SharePointRoot}/Templates/ControlTemplates

Put a Register element at the top of you page-layout

<%@ Register TagPrefix="MyOwnPrefix" TagName="MyUserControl" Src="~/_controltemplates/MyProjectName/UserControl.ascx" %>

and the refer to it where you need it like:

<MyOwnPrefix:MyUserControl runat="server" id="userControl" />
share|improve this answer
    
thank you, how should i deploy user control via solution? should i deploy it via module in a visual studio solution? –  ozdogan Sep 28 '12 at 6:52
    
Create a Mapped folder to {SharePointRoot}/Templates/ControlTemplates create a subdirectory and put the UserControl there –  Per Jakobsen Sep 28 '12 at 6:57
    
Thats it! Thank you. –  ozdogan Sep 28 '12 at 7:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.