May 14, 2010

Problem calling Java-script method from codebehind with master-page and update panel

we normally use
Page.ClientScript.RegisterStartupScript(this.GetType(), "key", "Sys.Application.add_load(method_Name);", true);
to call a javascript on runtime form code behind.
Placing the above code on page load or a button click makes the script to fire on the start up of subsequent postback.

But this make not work in the case where we give a
ajax post back intead of normal postback.

so to call a javascript method on ajax postback , here we go

ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Key", "ServiceDownAlert();", true);

Javascript Method:

function ServiceDownAlert() {
        alert("Image Not Available ! Please Try Later !");

No comments: