Resolved similar issue by adding check for page's ScriptManager.IsInAsyncPostBack
property. When it is set to false
you should use <control>.Page.ClientScript.RegisterExpandoAttribute
method.
I ended up with new extension method for Control
containing this logic:
public static void RegisterExpandoAttribute(this Control control, HtmlTextWriter writer, string attributeName, string attributeValue, bool encode = false)
{
var scriptManager = ScriptManager.GetCurrent(control.Page);
if (scriptManager != null && scriptManager.IsInAsyncPostBack)
ScriptManager.RegisterExpandoAttribute(control, control.ClientID, attributeName, attributeValue, encode);
else
control.Page.ClientScript.RegisterExpandoAttribute(control.ClientID, attributeName, attributeValue, encode);
}