473,768 Members | 8,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1893
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*******@disc ussions.microso ft.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
12432
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, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
2
8893
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 buttons: Accept and Cancel. When press the Accept button, the browser is closing, and when press the Cancel button, the browser isn´t closing. I have tried with the event onunload, but this closes first the browser, and
3
1861
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 Index.html. After finishing its work, it should spawn a new browser and display the updated Index.html file. How can I do that? Thank you for any response.
1
3036
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 close the windows using X box. I want the pop-up to be displayed when the user clicks on the X box of the browser window (namely, when the user closes the browser window). It's not important whether the data is changed or not. onbeforeunload event...
8
3119
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 parameters that should not be exposed. Each user is associated with a school, and should see only that school's data. When the user logs in, I retrieve the SchoolID associated with that user, and that SchoolID is used as a parameter in all stored...
6
2106
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 Session_End(Object sender, EventArgs e) when the user closes the browser window?
13
3559
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 some javascript code that calls window.open. I pass the resource url of page B to Page A's window.open call. Page B is then loaded and executed but none of the server-side code is rendered. If I view the source of the page, the code (and page...
3
1991
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 window is launched asking the user which file he /she wants to download. After the user determines which file to download, the window disappears but the user is provided with the download file dialog box. I have been able to track it down to a...
1
1739
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 cookies. There is a link to launch site B from Site A. User clicks the link and is shown Site B - b.aspx. I have a crystal report on b.aspx which user can run. Crystal report is exported into pdf and saved to a folder on the server and displayed to...
0
9576
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
9407
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9961
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
9843
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
8840
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
6656
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
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
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
3534
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.