TaxonomyWebTaggingControl in UpdatePanel with AJAX

When asyncronuous postback will happen it will not load the TaxonomyWebTaggingControl because DOM gets null.
Use below methode to load TaxonomyWebTaggingControl  after asyn postback.

private string GetReloadJavaScript(TaxonomyWebTaggingControl taxonomyControl)
            String script = String.Empty;
            String containerId = SPEncode.ScriptEncode(taxonomyControl.Controls[1].ClientID);
            Type type_TaxonomyWebTaggingControl = typeof(TaxonomyWebTaggingControl);
            MethodInfo mi_getOnloadJavascript = type_TaxonomyWebTaggingControl.GetMethod(“getOnloadJavascript”, BindingFlags.NonPublic | BindingFlags.Instance);
            String fullScript = (String)mi_getOnloadJavascript.Invoke(taxonomyControl, null);
            int pos = fullScript.IndexOf(String.Format(“function {0}_load()”, containerId));
            if (pos > -1)
                StringBuilder builder = new StringBuilder();
                builder.Append(“var myPrm_” + taxonomyControl.ID + ” = Sys.WebForms.PageRequestManager.getInstance();”);
                builder.Append(“myPrm_” + taxonomyControl.ID + “.add_endRequest(EndRequest_” + taxonomyControl.ID + “);”);
                builder.Append(“function EndRequest_” + taxonomyControl.ID + “(sender, args)”);
                // we get te first part of the script needed to initialization
                // we start from pos 1, because we don’t need the leading ‘{‘
                builder.Append(fullScript.Substring(1, pos – 1));
                script = builder.ToString();
            return script;

How to call above methode

String key1 = “TaxonomyWebTaggingAjaxIncludeOnce1”;
                if (!this.Page.ClientScript.IsClientScriptBlockRegistered(base.GetType(), key1))
                    this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), key1, GetReloadJavaScript(taxanomyProjectCategory_taxonomyControl), true);


give multiple call to methode for all taxonomy controls on page.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s