HowTo: Launch JavaScript after async postback of UpdatePanel

Assume the scenario where you want to launch a JavaScript function after your UpdatePanel finished to do its async postback. This turns out to actually be quite simple. What you do is to use the ScriptManager.RegisterStartupScript(...) method.
ScriptManager.RegisterStartupScript(btnSave, this.GetType(), "myScriptKey", "myFunction()", true);
The only thing I found that people misdo is to not specify the correct instance (1st parameter) that caused the asynchronous postback to fire and thus the UpdatePanel to do the postback. In such a case it will just fail silently.
Kindle

Comments

0

Your ad here?