window close eventhttp://forums.asp.net/t/1237752.aspx/1?window+close+eventFri, 17 Apr 2009 13:03:39 -040012377522251834http://forums.asp.net/p/1237752/2251834.aspx/1?window+close+eventwindow close event <p>Hi,</p> <p>&nbsp;In my web application,&nbsp;I need to do certain things like clearing the session when the user clicks on close button in browser. </p> <p>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?</p> <p>Also, can we prevent the same form to be opened twice?</p> <p>&nbsp;Thanks in Advance</p> 2008-03-24T20:16:12-04:002251925http://forums.asp.net/p/1237752/2251925.aspx/1?Re+window+close+eventRe: window close event <p>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().</p> <p>Not quite sure about this one......are you talking about the X close button OR your own custom button?</p> 2008-03-24T21:01:34-04:002251952http://forums.asp.net/p/1237752/2251952.aspx/1?Re+window+close+eventRe: window close event <p>&nbsp;why not handling that in your global.asax session_end event where you can clear out your session.<br> </p> 2008-03-24T21:12:32-04:002251972http://forums.asp.net/p/1237752/2251972.aspx/1?Re+window+close+eventRe: window close event <p>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...</p> <p>EDIT: I mean you have to write code to call some server side function which call a Session.Clear or the like, but&nbsp; I don't know how to write so...</p> 2008-03-24T21:20:25-04:002255401http://forums.asp.net/p/1237752/2255401.aspx/1?Re+window+close+eventRe: window close event <p>Hi Shobana P.S ,</p> <p>You can open a new&nbsp;page when user close a page window.</p> <p>&lt;body &nbsp; language=&quot;javascript&quot; &nbsp; onunload=&quot;window.open('sessionAbandon &nbsp; .aspx',null,'height=100,width=100')&quot;&gt;&nbsp;&nbsp; </p> <p>Then you can clear the session, and close the window, do't send html to user.</p> <p>Let me know if I have misunderstood what you mean. <br> Thanks.<br> Hope it helps,<br> Hua Jun </p> <p>&nbsp;</p> 2008-03-26T04:01:19-04:002996059http://forums.asp.net/p/1237752/2996059.aspx/1?Re+window+close+eventRe: window close event <p>but in case i dont want to do this on refresh then what to do ?</p> <p>Because unload event will fire in both case</p> 2009-03-10T10:21:58-04:003097910http://forums.asp.net/p/1237752/3097910.aspx/1?Re+window+close+eventRe: window close event <p>What if user opened it in multiple window and try close the any one of the window?</p> 2009-04-17T13:03:39-04:00