by Andreas

Sharepoint 2010 – Adding TaxonomyFieldControl to custom Page Layout

When attempting to add a taxonomy field control to your custom page layout, it will automatically be given a tag looking something similar to this:

<CustomTag_0:TaxonomyFieldControl FieldName="81d247d1-0373-4a2d-9e81-d4b69bf3e091" runat="server"></CustomTag_0:TaxonomyFieldControl>

When attempting to render this in Sharepoint Designer you’ll be told that “TagPrefix is not registered in this Web Form”:

image

If you’re one of those painfully optimistic characters you’ll still attempt to run it in the browser, which gives you the  ASP.NET error screen with the following message:

Parser Error Message: Unknown server tag ‘CustomTag_0:TaxonomyFieldControl”

For those who wants to dig even deeper than this, the following error message appears in the application event log:

Load control template file /_controltemplates/TaxonomyPicker.ascx failed: Could not load type ‘Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker’ from assembly ‘Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’.

 

The solution is simple: just add a reference to the assembly which contains the Taxonomy Picker control at the top of your Page Layout:

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

Then change the <CustomTag_0:TaxonomyFieldControl> to <Taxonomy:TaxonomyFieldControl> and off you go (remember there is a closing tag too, by the way..):

<Taxonomy:TaxonomyFieldControl FieldName="81d247d1-0373-4a2d-9e81-d4b69bf3e091" runat="server"></Taxonomy:TaxonomyFieldControl>

8 comments on “Sharepoint 2010 – Adding TaxonomyFieldControl to custom Page Layout

  1. Thanks for this good article, it has come handy several times after I’ve forgotten which assembly I needed to register.

  2. Krupesh on said:

    Hi Dude…

    I tried this but its not working for me…
    It is giving me following error…

    I am trying to add “Enterprise Keywords” Fields to my custom application page.

    GUID is for Enterprise keywords…

    Error:
    ===========================================================================
    Server Error in ‘/’ Application.
    ——————————————————————————–

    Form control does not have ControlMode set.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.SharePoint.SPException: Form control does not have ControlMode set.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SPException: Form control does not have ControlMode set.]
    Microsoft.SharePoint.WebControls.FormControlHelper.get_ControlMode() +21895748
    Microsoft.SharePoint.WebControls.BaseFieldControl.OnInit(EventArgs e) +69
    System.Web.UI.Control.InitRecursive(Control namingContainer) +143
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Control.InitRecursive(Control namingContainer) +391
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1477

    ——————————————————————————–
    Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456

    ===========================================================================

    Please help me to fix this…asap…

    Thanks,
    Krupesh Patel
    email me please or call me… by emailing me first,…

  3. Krupesh on said:

    I have used this code…

  4. Krupesh on said:

    lessthan sign
    Taxonomy:TaxonomyFieldControl FieldName=”23f27201-bee3-471e-b2e7-b64fd8b7ca38″ runat=”server”
    greaterthan sign

    lessthan sign
    /Taxonomy:TaxonomyFieldControl
    greaterthan sign

  5. Thanks this really helped me out.

  6. Kesava on said:

    thanks a lot … it worked like a charm…. and I did the same things that you said at the opening of this article.. quite impressive…

  7. Henrik on said:

    Thanx for posting this :)

  8. Jeff on said:

    Exactly what I was looking for. Thanks for the post

Leave a Reply

Your email address will not be published. Required fields are marked *

*

55,201 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>