473,804 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2837
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*****@MicroZ oft.com> wrote in message
news:43******** **************@ text.nova.plane t.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******** ******@TK2MSFTN GP14.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*****@MicroZ oft.com> wrote in message
news:43******** **************@ text.nova.plane t.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=JavaSc ript>
function WarnBeforeExit( ) {
...
}
window.onbefore unload = 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.Attrib utes.Add("oncli ck", "javascript:hdn BypassWarning.
value='true';")

Then in your WarnBeforeExit( ) function:
if (document.form. hdnBypassWarnin g.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.c om
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
2769
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 this would be simple enough if the ASP didn't have any user input, but it does.
0
1911
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 : Shutdown/reboot/logoff. I have tried this : AddHandler Microsoft.Win32.SystemEvents.SessionEnding, AddressOf
6
9435
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
1835
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 closing event: // Exit is a bool var false by default // when i want close rather than hide i set Exit to true if (!Exit){ e.Cancel = true; }
5
8116
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 thread is aborted by the system. How is one to keep the background thread from calling form.Invoke after the form's window handle has been destroyed? This is definitely happening in my application. I haven't read anything about this problem in...
2
2322
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, and I'm baffled. I've done some more Google searches and have come up with the same thing. A portion of the code is below. I call the HookSessionEnding routine in the Load event of the main form, but the shutdown event code never fires. I'm baffled....
6
11272
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 if i attempt to do so once again ? Does anybody have any does why this would be so ?
8
3456
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 likely something ive declared in my program that is preventing the logoff, i have tried closing and disposing forms and sql connections, is there anything else i should be looking for ? Or some way to step through it to find what is causing this ...
12
17066
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 is being closed? It is easy enough if the user selects "exit" from this tray icon but how can you detect if Windows is closing the program down? Normally I would simply do something in the Form.Closing event but without a form how can you...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.