473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

detect IE shutdown or closing form

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
Nov 20 '05 #1
3 2809
You can handle the client side onbeforeunload event. However, that event
will fire even if the page is just posting back to itself, so you need to
figure in that code if the user just did something on your form forcing it
to post back, or if it is something else.

"someone" <so*****@MicroZoft.com> wrote in message
news:43**********************@text.nova.planet.nl. ..
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

Nov 20 '05 #2
Thanks, Marina!

"Marina" <so*****@nospam.com> schreef in bericht
news:uW**************@TK2MSFTNGP14.phx.gbl...
You can handle the client side onbeforeunload event. However, that event
will fire even if the page is just posting back to itself, so you need to
figure in that code if the user just did something on your form forcing it
to post back, or if it is something else.

"someone" <so*****@MicroZoft.com> wrote in message
news:43**********************@text.nova.planet.nl. ..
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


Nov 20 '05 #3
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
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
0
by: Allan Bredahl | last post by:
Hi All I am trying to construct an application that is able to cancel a machine shutdown, reboot or logoff. And after performing some stuff to perform the original shutdown order :...
6
by: Adnan Hebibovic | last post by:
Hello developers How can I detect Windows shutdown from .NET and I mean clean .NET not catching the events with Win32 API ... Thanks
2
by: Du Dang | last post by:
I tried to implement a feature like msn or yahoo messeger, where the user click the "x" button, the form just hide itself to the tray icon. I got it to work by added the following code to the...
5
by: Stephen Lamb | last post by:
I have a background worker thread which I start from a form's HandleCreated event that makes calls back to the form using Invoke. During shutdown the form is disposed and the background worker...
2
by: Paul Steele | last post by:
Some time ago I tracked down the code for detecting the shutdown event within a C# program. I tested it, it worked, and I moved on. However, I just discovered that the code is no longer working,...
6
by: Jm | last post by:
Hi All I have a simple vb.net app that once run for some reason does not allow me to log off or shutdown the pc ? When i try to do so it will close my app and then will only shutdown or logoff...
8
by: Jm | last post by:
Hi All I have an app that when running if a user selects logoff or shutdown from the start menu, it will close itself but not logoff windows or shutdown. From what i have found so far its most...
12
by: Patrick Dugan | last post by:
I have an vb.net application that is a module that uses a "application.run" in the sub main to start. There is no form involved (just a system tray icon) How can you detect when the application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.