I placed the following code in two pages.
- A simple aspx page, there it worked well.
- 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());
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.