M B HONG 20 wrote:
I am developing an ASP.NET (C#) application and need some help. I wish
to call a server-side function (in the code-behind "file.aspx.cs") upon
a user clicking on the "X" to close the browser window. Is there a way
to postback and call a server-side function when this happens? I am
aware of the browser's native "onunload" event, but am not certain that
what I'm looking for is actually possible.
Traditionally the onunload handler has not been a reliable way to get
any communication done with the server. Some browsers (IE since IE 5,
Firefox, newer Mozillas) provide an onbeforeunload handler where you
might have more chances. But that handler brings up a dialog window
asking the browser user to confirm that he wants to navigate away. And
script in that handler cannot check what the user does in the dialog.
And both onunload and onbeforeunload are fired too when links are
followed, form submitted, new URLs loaded after being entered in the
location bar, you cannot precisely distinguish whether some tries to
close a browser window or navigates to a new URL.
--
Martin Honnen
http://JavaScript.FAQTs.com/