[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to handle the close(X) event of a browser

Posted on 2004-10-04
6
Medium Priority
?
186 Views
Last Modified: 2010-04-06
Hi,
I am developing a web application using asp.net. I want to handle the close(X) event of the browser and want to do some database updation before closing the browser. How can i do this?

regards
sudhir
0
Comment
Question by:sudhir_arao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 100 total points
ID: 12224315
Hi sudhir_arao,

Use Javascript onunload in the <body> tag. Have it call __doPostBack (not sure since not too good with ASP, but heard of it)

Regards,
Zyloch
0
 
LVL 6

Assisted Solution

by:snavebelac
snavebelac earned 100 total points
ID: 12224689
It is very difficulty to trap the closing of a browser as there is no specific event associated with it.  The onUnload event will trigger when a user closes the browser, refreshes, clicks the back button or goes to another page.  There is no way of knowing which has been carried out.

The only way to know when a user has stopped using your web page is via the 'Session_OnEnd' either via a logout of some sort or a timeout on the server.

I am not familiar with ASP.NET but with ASP the global.asp file holds the Session_OnEnd event which will trigger code at the server when a user logouts (associated with the session.adandon function in ASP) or when the session times out (default 20 mins).

HTH

C
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12225255
Ah yes, use onclose for Mozilla, for IE, here's an implementation: http://experts-exchange.com/Web/Web_Languages/JavaScript/Q_20926025.html

Regards...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question