Thursday, August 15, 2013

Calling JavaScript method from Server Side under Update Panel Postback

When you try to use the normal way of Calling a JavaScript method from Sever side in a Update Panel Postback, your JavaScript method will never be called. Since Update Panel makes Asynchronous calls you need to use “ScriptMananger” to register your client script from code behind instead of Page.ClientScript.

If your registering the Script under Update Panel Postback use the below line to register your client script.

ScriptManager.RegisterStartupScript(updatepanelID, updatepanelID.GetType(), "Reset", "MethodName();", true);
If your registering the Script under normal Postback use the below line to register your client script.

Page.ClientScript.RegisterStartupScript(this.GetType(), "Reset", "MethodName();", true);
Related Posts Plugin for WordPress, Blogger...