0

I am Unable to close current asp.net page using C# code. I tried:

ClientScript.RegisterClientScriptBlock(Page.GetType(), 
                                       "script", 
                                       "window.close();", 
                                       true);

I am not getting any error, but it doesn't work.

Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
John
  • 704
  • 3
  • 12
  • 29

2 Answers2

1

Try the following link

Programmatically close aspx page from code behind

Based on the scenario it may very. Please read the above thread replies

Also the following link shows the same question

How to close the current tab in the server side button click?

Community
  • 1
  • 1
Akhil
  • 1,918
  • 5
  • 30
  • 74
  • in this "Programmatically close aspx page from code behind" marked answer is closing window but it does not perform other things written on button click event. – John Feb 13 '14 at 07:52
1

Try this

ClientScript.RegisterStartupScript(typeof(Page), 
   "closePage", 
   "window.close();",
    true);
Dumisani
  • 2,988
  • 1
  • 29
  • 40