SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to retrieve the selected TaxonomyField value that the user selects from the TaxonomyWebTaggingControl rather than just a string representation. The idea being to eventually create a TaxonomyFieldValue object from that result. i.e.

string selectedTaxonomyTerm = this.TaxonomyWebTaggingControl.Text; // represents the selected term's Label | Guid

TaxonomyFieldValue taxonomyFieldValue = TaxonomyFieldControl.GetTaxonomyValue(selectedTaxonomyTerm); // Converts to a TaxonomyFieldValue object, however ValidateString throws exception because no TaxonomyField is assigned.

// what i want
var selectedTaxonomyField = this.TaxonomyWebTaggingControl.Field // Get the selected Field 
var newTaxonomyValue = new TaxonomyFieldValue(selectedTaxonomyField);

So basically i want a way to retrieve the underlying TaxonomyField from the selection of the TaxonomyWebTaggingControl. Any help would be great.

share|improve this question

Just get the field from the list and then cast it to a TaxonomyField like this:

SPListItem item = ...;
TaxonomyField taxField = item.Fields["FieldName"] as TaxonomyField;
TaxonomyFieldValue taxFieldValue = new TaxonomyFieldValue(taxField);
share|improve this answer
+1 I would probably use list.Fields intead of item.Fields – Jorge Carvalho Oct 9 '11 at 14:27

I like Wictor's answer and already vote it up. But it might not fit your question, so I'll add my 2 cents here too.

Another approach you might want to explore, if you're looking for a more abstract way of putting this in the control, could be to go through the TaxonomyHiddenList, look for a term based on your label, and get all the information you need from the TaxonomySession. Is it worth the extra trouble? What is your scenario?

share|improve this answer

Your Answer


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.