Question

I placed the following code in two pages.

  1. A simple aspx page, there it worked well.
  2. A page contains a lot of controls and Update Panels. There the code did not work. So I experimented with PageRequestManager.

Anybody know what should I do to execute the same in context of Case 2.

StringBuilder jScript = new StringBuilder();

jScript.Append("<script type='text/javascript'>");
jScript.Append("Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AlertMe);");
jScript.Append("function AlertMe() {");
jScript.Append("    alert('Hi Hoo')");
jScript.Append("}");
jScript.Append("AlertMe();");
jScript.Append("</script>");

Page.ClientScript.RegisterStartupScript(typeof(string), "save_as", jScript.ToString());
Was it helpful?

Solution

i am not sure i understand you right, but may be you are searching for function

ScriptManager.RegisterStartupScript()

because Page.ClientScript is obsolete now, and it's function "RegisterStartupScript" does not work with update panels async postbacks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top