Anyname Donotcare
Anyname Donotcare

Reputation: 11393

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

I try to close my current tab after confirm so i put the following code at the end of my confirm button , but the tab doesn't close !


   string jScript = "<script>close_window();</script>";
   ClientScript.RegisterClientScriptBlock(this.GetType(), "keyClientBlock", jScript); 

Upvotes: 3

Views: 24901

Answers (3)

user3405179
user3405179

Reputation: 184

I Just Add Following code on button.

OnClientClick="javascript:window.close();"

Upvotes: 1

Felipe Oriani
Felipe Oriani

Reputation: 38598

If you want to close the current window, you could try this:

string jScript = "<script>window.close();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "keyClientBlock", jScript);

Upvotes: 5

panky sharma
panky sharma

Reputation: 2159

This might help

Response.Write("<script>parent.close_window();</script>");

Upvotes: 1

Related Questions