How to add the managed metadata field to a custom page layout ? This need to done through visual studio. Any thoughts ?


These are the steps I have done so far. I'm doing it in VS and deploying the same to SP Server.

  1. Added a layout column (site column) like this.
> <Field Type="TaxonomyFieldType" DisplayName="Contextual Help Contexts
> New" Required="FALSE" ID="{F2189C6B-910D-45AA-9FD8-E5B9DBC7AC1A}"
> Name="ContextualHelpContextsNew"
> StaticName="ContextualHelpContextsNew" Group="SPDP Columns" />
  1. Added this new field in the ContentType.
> <FieldRef ID="{F2189C6B-910D-45AA-9FD8-E5B9DBC7AC1A}"
> Name="ContextualHelpContextsNew" />
  1. Referenced the field in PageLayout like this.
>        <div id="PageContentMain">     
>             <PublishingWebControls:RichHtmlField FieldName="PageContentMain"
> runat="server"></PublishingWebControls:RichHtmlField>
>             <Taxonomy:TaxonomyFieldControl FieldName="ContextualHelpContextsNew" InputFieldLabel="Help Contexts"
> runat="server"></Taxonomy:TaxonomyFieldControl>
>         </div>

Whats going wrong ?

  • 1
    First step add a managed metadata column, its related notes field and the two TaxCatch fields to the related content type of the page layout. Then just add a TaxonomyFieldControl to the page layout – Robert Lindgren Feb 23 '14 at 8:57
  • I have updated the question. Please suggest what all changes needed. I'm totally new to the technology. Thanks for your help. – Anish V Feb 23 '14 at 9:20
  • Here is a better way of provisioning the field wictorwilen.se/Post/…, less based on XML – Robert Lindgren Feb 23 '14 at 9:26
  • I cannot use a server side code. Currently we are keeping the layouts, contenttypes etc as an xml file in VS. While deploying these will we hosted in the server. Hence, I want the changes in xml file. – Anish V Feb 23 '14 at 10:44
  • Then you will have to provision the notes field that will be bound to the taxonomy field as well as add the two TaxCatch fields to the content type xml. You will also have to make sure that the new content type changes gets pushed out to all libraries – Robert Lindgren Feb 23 '14 at 11:14

What I suggest is,

Create Site Columns as follows

    DisplayName="ABC Code"
    Group="Custom Site Columns"
    Description="To display ABC Codes"
          <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">
      DisplayName="ABC Code Text"
      Group="Custom Site Columns"
      ShowInNewForm="FALSE" />

Associate the Taxonomy and Note fields using server side code in some feature activation event.

Guid fieldIdTextField = new Guid("{2169B2F2-43E4-460A-9999-84094F0A0A30}");

Taxonomyfield.TextField = fieldIdTextField ;


Add the site column to CType

<ContentType ID="0x0100B83402A1721B4A3099A8AC91E3A7E6C4" 
               Group="Custom Content Types" 
               Description="This content type will have a list of site columns required to create a quote request." 
      <FieldRef ID="{2CB503A2-0FCB-465A-9BD9-31D60D12A21A}" DisplayName="ABC" Required="FALSE" Description="To display ABC Codes" Name="ABC" />

Add the CType to PageLayout in its Elements.xml file

<File Path="PageLayouts\PageLayout.aspx" Url="PageLayout.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  Level="Published" ReplaceContent="true">
      <Property Name="Title" Value="PageLayout Title"></Property>
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;"></Property>
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
      <Property Name="PublishingAssociatedContentType" Value=";#CType;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900A22F433C8ABF4216B2F384B38BF6F2C7;#" />

Open the Pagelayout in SharePoint designer and show the toolbox which will show the fields from your associated content type of the pagelayout. Just drag and drop the field which will create the mark up for you and it adds the register tag also at the top of the page. You don't really need to type anything manually which is vulnerable.

Let me know if you have any questions.


Have you registered the Taxonomy control assembly/namespace in your page layout?

You should have something such as the following in top of your layout page:

<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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