Sunday, August 24, 2008

Calling Javascript from an UpdatePanel

You've probably used ClientScript.RegisterStartupScript in your ASP.NET application and it works just fine. However, if you try it within an UpdatePanel control, you would notice that it simply doesn't execute.

The solution to this problem is to use ScriptManager.RegisterStartupScript instead. You can call it like so:
ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType(), "key", "alert('My script');", true);

7 comments:

  1. Awesome. You are legend

    ReplyDelete
  2. look at this link, you might find an answer:
    http://www.systemdeveloper.info/2014/01/fileupload-control-in-update-panel.html
    or in
    http://www.systemdeveloper.info/2014/02/how-do-i-add-javascript-updatepanel-in.html

    ReplyDelete