473,394 Members | 1,813 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,394 software developers and data experts.

How to capture browser close event when user click on x?

Hi,

In our asp.net app, we need to capture the event when user
close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone
show me how to do this?

Thanks
Nov 18 '05 #1
4 5497
"feng" <an*******@discussions.microsoft.com> wrote in news:3cb001c3fdb6
$7****************@phx.gbl:
In our asp.net app, we need to capture the event when user
close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone
show me how to do this?


You have to hook the JS evente onunload - but its not 100% reliable in all
versions of IE.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Nov 18 '05 #2
Can you elaborate on what your overall business goal is here? OnOnload may
work for your needs, but trapping native Windows actions (E.g. clicking on
Window chrome) is not trivial.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"feng" <an*******@discussions.microsoft.com> wrote in message
news:3c****************************@phx.gbl...
Hi,

In our asp.net app, we need to capture the event when user
close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone
show me how to do this?

Thanks

Nov 18 '05 #3
our web application uses a RPC connection to start a Unix
backend runtime environment, which takes a considerable
amount of resource. It is critical that we make sure that
if a user exit the application, the RPC will be killed as
soon as possible. We are currently relys on session_end
event handler to do this. But it doesn't seem to be
enough. Depending on the sessin time out setting, each
user may leave several runtime environments on the backend
waitting for clearing. This is very bad and we need to do
something better.

An ideal solution will be: when user click on the "x"
button on their browser, we capture the event and clear
the resource. The only problem becomes, how to capture the
event. I tried OnUnload, but it doesn't seem to be
reliable.

Any other ideas?

Thanks
-----Original Message-----
Can you elaborate on what your overall business goal is here? OnOnload maywork for your needs, but trapping native Windows actions (E.g. clicking onWindow chrome) is not trivial.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
"feng" <an*******@discussions.microsoft.com> wrote in messagenews:3c****************************@phx.gbl...
Hi,

In our asp.net app, we need to capture the event when user close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone show me how to do this?

Thanks

.

Nov 18 '05 #4
Can you show me how you're using the OnUnload event?
http://msdn.microsoft.com/library/de...s/onunload.asp
indicates that it should fire when the browser window closes-- How are you
trying to signal the server at that point?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"feng" <an*******@discussions.microsoft.com> wrote in message
news:3a****************************@phx.gbl...
our web application uses a RPC connection to start a Unix
backend runtime environment, which takes a considerable
amount of resource. It is critical that we make sure that
if a user exit the application, the RPC will be killed as
soon as possible. We are currently relys on session_end
event handler to do this. But it doesn't seem to be
enough. Depending on the sessin time out setting, each
user may leave several runtime environments on the backend
waitting for clearing. This is very bad and we need to do
something better.

An ideal solution will be: when user click on the "x"
button on their browser, we capture the event and clear
the resource. The only problem becomes, how to capture the
event. I tried OnUnload, but it doesn't seem to be
reliable.

Any other ideas?

Thanks
-----Original Message-----
Can you elaborate on what your overall business goal is

here? OnOnload may
work for your needs, but trapping native Windows actions

(E.g. clicking on
Window chrome) is not trivial.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and

confers no rights.

"feng" <an*******@discussions.microsoft.com> wrote in

message
news:3c****************************@phx.gbl...
Hi,

In our asp.net app, we need to capture the event when user close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone show me how to do this?

Thanks

.

Nov 18 '05 #5

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

Similar topics

2
by: Derek | last post by:
Hello: I want to capture the event when a browser is closing, to give to the user the posibility of close or no this browser. When the browser is closing, this show a confirm window with two...
1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
3
by: Benjamin Gavin | last post by:
Hi all, I recently stumbled upon a bug in the ASP.NET framework handling of ImageButton based postbacks. The issues derives from the fact that IE and Mozilla handle the case of a missing image...
5
by: Uma Muthu | last post by:
Hello Everyone, How can I capture the event of closing the IE browser from within an ASP.NET web application? TIA, Uma
4
by: Bill Manring | last post by:
I need to capture the event when the user closes the browser in my application. I have some code in the session_End event, which works fine when the session times out, but I need to end the...
5
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
1
by: Feng | last post by:
Hi, Need help on the following issue. We need to clean up some session specific backend resource when a user ends his session. We have a "Logoff" button on the pages that handles that. But...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
1
by: karthik juneni | last post by:
Hi all, Iam trying to capture windows closing event (i.e) when the user clicks on the "X" button i want to capture that event and want to update some values in the database.I tried two methods...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.