In my web application, I need to do certain things like clearing the session when the user clicks on close button in browser.
Is there any event. dont tell me unload event, because this will be triggered each time of post back. I want a event that will be triggered only when user clicks on close button?
Also, can we prevent the same form to be opened twice?
Shobana P.S
Member
479 Points
130 Posts
window close event
Mar 24, 2008 08:16 PM|LINK
Hi,
In my web application, I need to do certain things like clearing the session when the user clicks on close button in browser.
Is there any event. dont tell me unload event, because this will be triggered each time of post back. I want a event that will be triggered only when user clicks on close button?
Also, can we prevent the same form to be opened twice?
Thanks in Advance
Shobana
Self Taught
Member
267 Points
56 Posts
Re: window close event
Mar 24, 2008 09:01 PM|LINK
Off hand I think you would have to write an event to capture the close button being pushed, then inside there you could do Session.Clear().
Not quite sure about this one......are you talking about the X close button OR your own custom button?
>> 0 rows returned
karan@dotnet
All-Star
26228 Points
4596 Posts
Re: window close event
Mar 24, 2008 09:12 PM|LINK
why not handling that in your global.asax session_end event where you can clear out your session.
Karan
~ Blog ~
Remember To Mark The Post(s) That Helped You As The ANSWER
deostroll
Member
517 Points
375 Posts
Re: window close event
Mar 24, 2008 09:20 PM|LINK
I believe you have 2 write client side code for the window.onbeforeunload event. But I don't know what to exactly write in there...
EDIT: I mean you have to write code to call some server side function which call a Session.Clear or the like, but I don't know how to write so...
Hua-Jun Li -...
All-Star
75950 Points
5608 Posts
Re: window close event
Mar 26, 2008 04:01 AM|LINK
Hi Shobana P.S ,
You can open a new page when user close a page window.
<body language="javascript" onunload="window.open('sessionAbandon .aspx',null,'height=100,width=100')">
Then you can clear the session, and close the window, do't send html to user.
Let me know if I have misunderstood what you mean.
Thanks.
Hope it helps,
Hua Jun
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
nisheeth.tak
Member
12 Points
6 Posts
Re: window close event
Mar 10, 2009 10:21 AM|LINK
but in case i dont want to do this on refresh then what to do ?
Because unload event will fire in both case
bala.vanchi
Member
12 Points
12 Posts
Re: window close event
Apr 17, 2009 01:03 PM|LINK
What if user opened it in multiple window and try close the any one of the window?