Click here to Skip to main content
15,071,581 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);
[no name] 4-May-15 5:10am
change this.GetType to GetType

Try this
<script language="JavaScript" type="text/javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
    return "Are you sure you want to exit this page?";
Dawood Abbas 4-May-15 5:01am
but I want throw it at codebehind side because before it I want to perform update functionalities.

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

Ref : show alert message from code behind using javascript
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 :)

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