Click here to Skip to main content
15,346,895 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to exit a page in asp.net via code and i search at internet there was only java script but i want to close page only in asp.net than please tell me which code is used to exit a asp.net page in website without java script and c# only in asp.net in visual studio 2010
Posted

Use the code below(Example to close page on button click event)

C#
protected void btnClose_Click(object sender, EventArgs e)
{
  ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);
}
   
You can not close window without using any code
Try below code

C#
Response.Write("<script type="text/javascript">window.close();</script>");
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900