The problem
How do you add a custom control to your master page (or page layout) using the Design manager? In my first attempts I continuously got ‘Unknown server tag ‘uc1:FeedbackControl’
Quick introduction
Using the new way of creating and deploying your branding with the Design Manager needs some getting used to. The idea is:
- You start with a plain html page
- SharePoint automatically converts it to a master page (or layout page)
- You only edit the html page. SharePoint pushes your changes to the master page
- Most of the SharePoint controls and web parts can be configured and added by copy + pasting snippets into your html
- .NET server controls can also be placed on your page by using snippets.
In fact snippets is nothing more than a special kind of mark-up to put server controls in your html page.
But how to you add a custom control?
I created my branding with the Design Manager. I also have a Visual Studio 2012 solution with custom web parts and custom user controls.
After deploying the Visual Studio solution to my server I tried to add some of my custom user controls to the master page. All attempts I made resulted in “Unknown server tag”
Defining your control.
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>-->
Putting your control on your page.
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet--> <!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl" />--> <!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->
The solution
The trick is easy. Instead of registering your control on top of the html together with all the default SharePoint controls. You need to put the @Register statement and your code together
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>--> <!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet--> <!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl" />--> <!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->
So you do NOT place the @Register-statement before the DOCTYPE declaration. Embed it directly into your html page together with your snippet.
One other tip.
I had some problems / errors with defining multiple controls with the same tag prefix. If you have multiple controls on a page give them all a different TagPrefix and you will be fine.
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>--> <!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/Notification.ascx" TagPrefix="uc2" TagName="Notification" %>--> <!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/DisplayStatus.ascx" TagPrefix="uc3" TagName="DisplayStatus" %>--> <!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet--> <!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl1" />--> <!--SPM:<uc2:Notification runat="server" id="Notification1" />--> <!--SPM:<uc3:DisplayStatus runat="server" id="DisplayStatus1" />--> <!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->








