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

We have taxanomy – TaxonomyWebTaggingControl placed on a admin control panel. We need to assign/set value(value is lookup value:keyword) to the control by using JavaScript.

Code is already written, but still it’s not displaying or setting up the values for TaxonomyWebTaggingControl.

<Taxonomy:TaxonomyWebTaggingControl ID="TaxonomyKeywords" runat="server" IsDisplayPickerButton="False"  WidthCss="taxonomyWidth" IsIgnoreFormatting="True" IsMulti="true">   

Below code is piece of code where the value is getting assigned –

document.getElementById('<%=TaxonomyKeywords.ClientID %>').value = Keywords[1]

We have tried by using following ways

1.Observations 1: Is Lookup value:keyword itself is coming?

we have take the simple textbox, and do the same thing – Values are getting displayed there. SO,DEFINITELY values are getting retrieved from the SharePoint list.

So..this is how we declared it….

 <input id="txtKeyWord"....

In this Case, keywords are displayed in text box, but as we are displaying it lookup value and we need to store as a termset value we have to use TaxonomyWebTaggingControl control.

2.Observations 2 : We tried with another approach

function setTaxonomyControlObjectValue(webTaggingId, termValue) {
   var webTaggingCtl = $get(webTaggingId);
   var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(webTaggingCtl);

function initCountryTaggingControl(){
   var countriesControlId = "ctl00_PlaceHolderMain_ctl03";
   var continentTermValue = "Africa|43f3b1e7-e40c-45d2-a613-88643668d373";
   setTaxonomyControlObjectValue(countriesControlId, continentTermValue);

ExecuteOrDelayUntilScriptLoaded(initCountryTaggingControl, 'ScriptForWebTaggingUI.js');

Still it’s not working…

Help is requested

share|improve this question

If your first piece of code is working I'd expect you to be getting a set of nested <span> and <div> tags, with the innermost being something like -

<div style="width: 362px;" title="[MyTermset]" class="ms-taxonomy-fieldeditor">
    <div ...  role="textbox" ... id="TaxonomyKeywordseditableRegion" contenteditable="true">?</div>

From your quote it seems that isn't the case, but if you have a metadata term entry field appearing in the page then it's working.

If so, you should be able to set the term (i.e. replace the '?' in the above) in the usual way, just as plain text.

You then need to get the ContainerId (i.e. the same ID without the 'editableRegion' part - so in your case TaxonomyKeywords) as a HtmlDivElement not a jQuery object. If you have it via jQuery do var myDivElement = myJQueryObject.get(0);. Then call a Microsoft function:

var controlObject = new Microsoft.SharePoint.Taxonomy.ControlObject(document.getElementById(myDivElement));

You should then have a validated term (i.e. black text with a solid underline, not red text with a dashed underline)

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.