473,387 Members | 1,483 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.

server needs to know when user closes browser window

Hi,

When user closes a browser window by clicking on the "X"
button, I want the server to be noticed (either through
postback or calling other ASP pages, etc.) and perform
some task accordingly. Please note that I can't use
session end event, since the session is still alive now
and the user is just closing a secondary window he/she
opened.

I tried to use the <BODY> tag's onunload client side event
and put a flag in a hidden textbox then submit the form
(post back). But this didn't work for me -- my code on the
server side can't really capture the event properly.

What's the proper way of doing this? Can anyone help me?

Thanks
Nov 18 '05 #1
1 1877
OnUnload is an option, but you have to have a method of speaking to the
server. Perhaps having the code navigate to another page that says "are you
sure you want to close this window" and having that page tell you they are
closing the window. But, that might tick off users.

The difficulty here is HTTP is stateless, which means the client is
disconnected once they have recieved a page. In an Intranet environment, you
have more options, of course.

If you can set up the popup window so there is no header bar (thus no X to
close) and put a "Close window" button, you have the ability to handle the
event on the server side, but this may end up causing a dialog stating
"someone is trying to close this window" or similar.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"feng" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
Hi,

When user closes a browser window by clicking on the "X"
button, I want the server to be noticed (either through
postback or calling other ASP pages, etc.) and perform
some task accordingly. Please note that I can't use
session end event, since the session is still alive now
and the user is just closing a secondary window he/she
opened.

I tried to use the <BODY> tag's onunload client side event
and put a flag in a hidden textbox then submit the form
(post back). But this didn't work for me -- my code on the
server side can't really capture the event properly.

What's the proper way of doing this? Can anyone help me?

Thanks

Nov 18 '05 #2

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

Similar topics

12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
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...
3
by: Teckie03 | last post by:
Hi, does anyone know how to display a seperate browser from server process? My ASP.NET app control (ascx) has Archive button that does its own work , including updating an html page called...
1
by: buran | last post by:
Dear ASP.NET Programmers, I am developing an intranet application using ASP.NET. I want to add such a functionality that the application displays a pop-up box to confirm when the user tries to...
8
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string...
6
by: Annie | last post by:
Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
3
by: bfmcfarlane | last post by:
I have an appication that allows users to upload and download files. This application is only accessed when a user clicks on an "Upload / Download" link from within our main application. A new...
1
by: pintoo | last post by:
Hi, I have 2 sites (Site A, B) running on same windows 2003 server pointing to different home directories. User logs into site A and is shown a.aspx page and user credentials are saved in...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.