To manipulate term values in TaxonomyWebTaggingControl control we’ll use Client Object model for Taxonomy, in particular ControlObject capabilities (it is not documented).
In order set the Taxonomy Control (TaxonomyWebTaggingControl) value on the client side the following function could be used:
//Set Taxonomy ControlObject value
//webTaggingId - TaxonomyWebTaggingControl ID
//termValue - represents a single value held in a TaxonomyField object using the following format: NameOfTerm|GUIDOfTerm
function setTaxonomyControlObjectValue(webTaggingId, termValue) {
var webTaggingCtl = $get(webTaggingId);
var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(webTaggingCtl);
taxCtlObj.enableControl(true);
taxCtlObj.setRawText(termValue);
taxCtlObj.retrieveTerms();
}
Note:
a) to find TaxonomyWebTaggingControl on the client side
webTaggingId identifier is used, that corresponds to ContainerId
property of control
b) termValue represents a single value held in a TaxonomyField
object using the following format: NameOfTerm|GUIDOfTerm
Usage
Example 1. Setting TaxonomyWebTaggingControl control value
//Example 1. Setting TaxonomyWebTaggingControl control value during event (page load, button click and etc.)
function initCountryTaggingControl() {
var countriesControlId = "ctl00_PlaceHolderMain_ctl03";
var continentTermValue = "Africa|43f3b1e7-e40c-45d2-a613-88643668d373";
setTaxonomyControlObjectValue(countriesControlId, continentTermValue);
}
ExecuteOrDelayUntilScriptLoaded(initCountryTaggingControl, 'ScriptForWebTaggingUI.js');
Note:
initCountryTaggingControl is executed after script
ScriptForWebTaggingUI.js is loaded
P.S. If you are interested how TaxonomyWebTaggingControl works on the client side and how to access and manipulate TaxonomyWebTaggingControl on the client side please follow this article.