0

I have problem with javascript. I have a master page (Page1.master) and Aspx page (Page2.aspx) when i redirecting from Page1.master to Page2.aspx, my Javascript function not getting triggered.

I have ScriptManager in both master and aspx page In my master page, i have like this

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

In my aspx page, i have UpdatePanel in addition to ScriptManager. It looks like

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upp" runat="server" UpdateMode="Always">
//other controls
</asp:UpdatePanel>

Here My javascript function:

ClientScriptManager cs = Page.ClientScript;
Type cstype = this.GetType();
string csname = "MyScript";
if (!cs.IsClientScriptBlockRegistered(cstype, csname))
{
System.Text.StringBuilder js = new System.Text.StringBuilder();
js.Append("<script language=JavaScript>");
js.Append("function closeWindow() {");
js.Append("if(myWindow == null) {");
js.Append("var myWindow = window.open('', 'myWindow'); }");
js.Append("myWindow.close();");
js.Append("}");
js.Append("</script>");
cs.RegisterClientScriptBlock(cstype, csname, js.ToString());
}
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "CloseWindowScript", "closeWindow();", true);

Can anyone help me to make it work.. Thanks

Naveen
  • 1
  • 1

0 Answers0