I have a ASP.NET web app with a MasterPage and contents page, from the MasterPage when I click a MenuItem
to open a new aspx Page. if I want to close the new page browser tab, I want to show a popup or a dialog that alert the user that he is closing the browser tab. I dont know how to detect the close browserTab button.
I used the following code in the new aspx page:
<script type="text/javascript">
function CloseWindow() {
alert('closing');
window.close();
}
</script>
new page code behind:
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
}
Thanx in Advantage.