Click here to Skip to main content
14,327,443 members
Rate this:
Please Sign up or sign in to vote.
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);
Posted
Comments
RajeeshMenoth 4-May-15 5:10am
   
change this.GetType to GetType
Rate this:
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

Hi,

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


Ref : Asp.net show alert message from code behind using javascript
   
Comments
Dawood Abbas 4-May-15 5:28am
   
I want to close it also.
RajeeshMenoth 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
RajeeshMenoth 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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100