ASP.NET Call JavaScript from UpdatePanel

In my case ScriptManager was initialized in Master.Master Page. Any try using ScriptManager.RegisterClientScriptBlock() failed bacuese of missing AJAX references.
One approach is described here.
My solution was to download AJAX library, adding a reference to it and code below:

protected void FlagTopic_Click(object sender, EventArgs e){     if (AjaxControlToolkit.ToolkitScriptManager.GetCurrent(this.Page) != null && AjaxControlToolkit.ToolkitScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)    {        AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(this, this.GetType(), "Initialize", "fireModal();", true);    }}

If you cannot use code like

ScriptManager.GetCurrent(Page).IsInAsyncPostBack

Change it to this

AjaxControlToolkit.ToolkitScriptManager.GetCurrent(Page).IsInAsyncPostBack

Leave a Reply

Your email address will not be published. Required fields are marked *