Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been trying with below code its getting execute but messagebox not displaying and tab also not getting close.

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "alert('Record Deleted successfully.Note: This tab is now getting close');", true);

so i just remove the 'alert' code from above code then its getting execute and getting close the tab. But I also want to display notification message box so how?

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "window.close();", true);
Updated 17-Jul-23 23:25pm
[no name] 4-May-15 5:10am    
change this.GetType to GetType


ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('Only alert Message');",true);

Ref : show alert message from code behind using javascript
Share this answer
Dawood Abbas 4-May-15 5:28am    
I want to close it also.
[no name] 4-May-15 5:42am    
k,then write this code.

function closeIt()
return "Any string value here forces a dialog box to \n" +
"appear before closing the window.";
window.onbeforeunload = closeIt;
Dawood Abbas 4-May-15 5:45am    
I got it..many many thanq M.r RajeeshMenoth
[no name] 4-May-15 5:46am    
Welcome always :)
Try this
<script language="JavaScript" type="text/javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
    return "Are you sure you want to exit this page?";
Share this answer
Dawood Abbas 4-May-15 5:01am    
but I want throw it at codebehind side because before it I want to perform update functionalities.
here is a problem when i click button thats redirect another page , that time also show it , but i only need for browser window or tab close .
Share this answer
Richard Deeming 18-Jul-23 6:39am    
Your question is not a solution to someone else's question.

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