473,405 Members | 2,344 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,405 software developers and data experts.

Server side actions on closing the browser window

Hi,

I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?

Jan 8 '07 #1
7 4401
No, there is no. You can try handling client-side window.onunload event to
pass something to the server.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Santel" <sa***********@sify.comwrote in message
news:11********************@i15g2000cwa.googlegrou ps.com...
Hi,

I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?

Jan 8 '07 #2
You pretty much need to hook into a javascript event (like onbeforeunload),
and fire some server side code - either be poping up a window or doing some
ajax.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Santel" <sa***********@sify.comwrote in message
news:11********************@i15g2000cwa.googlegrou ps.com...
Hi,

I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?
Jan 8 '07 #3
"Santel" <sa***********@sify.comwrote in message
news:11********************@i15g2000cwa.googlegrou ps.com...
I would like to do some server side actions while closing the browser
window. I tried with Page_Unload event, but it triggers while loading
the page itself. Anyone please tell me is there any event that triggers
on closing the page?
As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way, and
it will (sometimes) fire if the user clicks the Refresh button, which will
probably cause a lot more problems for you...

What are you trying to achieve with this...?
Jan 8 '07 #4
"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:u6**************@TK2MSFTNGP03.phx.gbl...
You pretty much need to hook into a javascript event (like
onbeforeunload),
The problem here is that onbeforeunload is not (currently) standard w3c, and
is not supported in all browsers:
http://forums.asp.net/thread/1362515.aspx
Jan 8 '07 #5
Hi Mark,

Mark Rae wrote:
As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way, and
it will (sometimes) fire if the user clicks the Refresh button, which will
probably cause a lot more problems for you...
Out of curiosity, in your experience, which browsers do not fire
window.unload when the page is refreshed?

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 8 '07 #6
"Laurent Bugnion [MVP]" <ga*********@bluewin.chwrote in message
news:uX**************@TK2MSFTNGP02.phx.gbl...
>As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way,
and it will (sometimes) fire if the user clicks the Refresh button, which
will probably cause a lot more problems for you...

Out of curiosity, in your experience, which browsers do not fire
window.unload when the page is refreshed?
Safari certainly didn't, though I haven't checked in the latest version...
Jan 8 '07 #7
Hi,

Mark Rae wrote:
"Laurent Bugnion [MVP]" <ga*********@bluewin.chwrote in message
news:uX**************@TK2MSFTNGP02.phx.gbl...
>>As Eliyahu says, you can (try to) use the window.unload event, but the
problem here is that not all browsers handle this event in the same way,
and it will (sometimes) fire if the user clicks the Refresh button, which
will probably cause a lot more problems for you...
Out of curiosity, in your experience, which browsers do not fire
window.unload when the page is refreshed?

Safari certainly didn't, though I haven't checked in the latest version...
Interesting. Thanks! That confirms what I thought, that this event is
not reliable.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 8 '07 #8

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: Solvig | last post by:
Server side and client side actions on one button in ASP.NET I am stuck. How do I find a start to a solution. After checking all fields in a form I want to save changes in the database, open a...
1
by: feng | last post by:
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...
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...
3
by: Sileesh | last post by:
Hi I hope some one has an answer to this. I have a button in an aspx page . On server click of this button, i perform some operation. Once the operation is performed i want to close this...
4
by: Kash | last post by:
Hi everybody: I've developed a web application running on a 2003 server not on the web but on extranet environment of a small Firm (less than 10 users). I've taken benefit of Office Primary...
5
by: genc ymeri | last post by:
Is anyway I can catch the event of client closing the browser in server side (ASP.Net) ??? Thanks in advance, Genc Ymeri.
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.