Adding the taxonomy control to a custom page

In my current project I’m dealing with different custom forms for my lists. The list contains a colum of type “managed metadata”.

In one of my custom display forms I wanted to add the taxonomy feature and the relevant properties from the column settings. To archieve that I did the following:

Adding a reference to the control:

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

Inserting the control:

<Taxonomy:TaxonomyWebTaggingControl ID="taxonomyCntrl" runat="server" />

In the code behind (C#) class I put the properties to the control:

public static TaxonomyField GetTaxonomyFieldOfList(string listname, string fieldname){
SPList questionList = SPContext.Current.Web.Lists[listname];
return questionList.Fields[fieldname] as TaxonomyField; }
-----------
TaxonomyField taxonomyInfo = SPListUtility.GetTaxonomyFieldOfList("list name", "Tags (=column name)");
if (taxonomyInfo != null) {
this.taxonomyCntrl.SspId.Add(taxonomyInfo.SspId);
this.taxonomyCntrl.TermSetId.Add(taxonomyInfo.TermSetId);
this.taxonomyCntrl.IsAddTerms = true;
this.taxonomyCntrl.AllowFillIn = true;
this.taxonomyCntrl.IsMulti = true;
}

This is the code to set the necessary properties for the managemend metadata.

For saving back the value to the list the following code could be used:

TaxonomyFieldValueCollection tfvc = TaxonomyFieldControl.GetTaxonomyCollection(this.taxonomyCntrl.Text);

Related Posts

  1. Fehler beim Anlegen einer MetadataColumn in SharePoint 2010
  2. Content Type Publishing Link wird nicht angezeigt bei Subscribers
  3. Nintex Workflow 2010
  4. Visual Studio 2010: Deploying Content Types and Site Columns
  5. SharePoint 2010: Open document vs. Download documents

One Response to “Adding the taxonomy control to a custom page”

  1. Peter Holpar 6 August 2010 at 10:43 #

    Hi,

    You can find similar solution on my blog here:
    Build your own user interface components using the taxonomy controls
    http://pholpar.wordpress.com/2010/02/15/build-your-own-user-interface-components-using-the-taxonomy-controls/

    …as well as further posts about the new taxonomy feature:
    http://pholpar.wordpress.com/category/taxonomies/

    Peter


Leave a Reply