Vignesh Kumar

Vignesh Kumar

  • NA
  • 1k
  • 418.1k

Close current window in asp.net without any confirmation

Dec 21 2018 3:42 AM
Hi,
 
I'm new to asp.net and trying to close current tab after button click without asking for any confirmation.
 
Can anyone pls help me out and below is the code I'm using.
  1. protected void btn_Click(object sender, ImageClickEventArgs e)  
  2. {  
  3. string strURL = string.Empty;  
  4. strURL = "Nav.aspx?ID=" + strID;  
  5. strURL = "window.open('" + strURL + "');";  
  6. ScriptManager.RegisterStartupScript(thisthis.GetType(), "pop", strURL, true);  
  7. ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "text""Close()"true);  
  8. }  
I tried below piece of code and it asks for confirmation. How can I close the window without confirmation prompt message?
  1. <script type="text/JavaScript" lang="JavaScript">  
  2. function Close()  
  3. {  
  4. window.close();  
  5. }  
  6. </script>  
A confirmation box shows up and it shouldn't come and the current window should be closed automatically upon button click.

Answers (1)