As Marina suggested, your best bet is JavaScript and mapping a function to
onbeforeunload:
Your HTML should end something like:
</BODY>
<script language=JavaScript>
function WarnBeforeExit() {
...
}
window.onbeforeunload = WarnBeforeExit();
</script>
One problem you may encounter is that some controls will cause a PostBack, in
which case you don't want the warning. In those cases you'll need to set a
variable/hidden field value so that your WarnBeforeExit() function will be
suppressed in those cases.
Example for your code-behind page:
myButton.Attributes.Add("onclick", "javascript
:hdnBypassWarning.
value='true';")
Then in your WarnBeforeExit() function:
if (document.form.hdnBypassWarning.value != 'true')
return 'I DO NOT WANT YOU LEAVING THIS PAGE DAMMIT';
HTH,
Darren
someone wrote:
Hi,
Is it possible to detect if the user has shut down the window holding my
ASP2.0 page and/or if the user goes to another page?
For my application I need the user to click on the EXIT button instead of
just going to another page or discard the window completely.
My application is in VB.NET ASP2.0.
thanks,
Eric
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1