Tuesday, 20 March 2012

Close page window using java script asp.net c#

How to close window from code behind using c# asp.net:

This code using the javascript script and its created / called dynamically the  from code behind:

Sample code:

string scriptstring = "var res=confirm('Are you sure want to close?)');if(res==true){window.close();}";
                ClientScript.RegisterStartupScript(this.GetType(), "alertscript", scriptstring, true);

(OR
)
string str = "window.close();";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertscript", str, true);

No comments:

Post a Comment