invoke a severside code when clicking browser close buton
-
hi , i am using asp.net2003 with c# i need to know how we can invoke a server side function when user click browser close button???
All I ever wanted is what others have....
CrazySankerYou can't.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
hi , i am using asp.net2003 with c# i need to know how we can invoke a server side function when user click browser close button???
All I ever wanted is what others have....
CrazySankerHandle the Javascript event and call an AJAX method.
only two letters away from being an asset
-
Handle the Javascript event and call an AJAX method.
only two letters away from being an asset
-
AJAX type techiques have been around since about 1997, they have only recently been named AJAX and come into vogue. It makes use of XMLHttpRequest which is independent from any version ASP.NET.
only two letters away from being an asset
-
AJAX type techiques have been around since about 1997, they have only recently been named AJAX and come into vogue. It makes use of XMLHttpRequest which is independent from any version ASP.NET.
only two letters away from being an asset
Mark Nischalke wrote:
AJAX type techiques have been around since about 1997, they have only recently been named AJAX and come into vogue. It makes use of XMLHttpRequest which is independent from any version ASP.NET.
And even before that similar techniques were used with hidden frames, minimal iframes and small image tags. :)
--- single minded; short sighted; long gone;
-
Mark Nischalke wrote:
AJAX type techiques have been around since about 1997, they have only recently been named AJAX and come into vogue. It makes use of XMLHttpRequest which is independent from any version ASP.NET.
And even before that similar techniques were used with hidden frames, minimal iframes and small image tags. :)
--- single minded; short sighted; long gone;
I've tried to suppress those memories ;P
only two letters away from being an asset
-
Ajax is simply a technique that you achieve using Javascript. For what you want you'd need to hook into the body's onunload event and fire a quick request to the server. Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't. Best not to rely on it.
-
Ajax is simply a technique that you achieve using Javascript. For what you want you'd need to hook into the body's onunload event and fire a quick request to the server. Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't. Best not to rely on it.
badgrs wrote:
Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't.
Please, elaborate on this. Why would the call never run?
only two letters away from being an asset
-
badgrs wrote:
Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't.
Please, elaborate on this. Why would the call never run?
only two letters away from being an asset
-
Basically because the page where code is running is already closing. You can hardly do anything there without opening a new window.
--- single minded; short sighted; long gone;
Strange. I have a project now were I'm calling an ajax method from the onunload script event and it seems to be working fine.
only two letters away from being an asset
-
badgrs wrote:
Of course there is no guarantee that this will ever run, and I'm pretty sure the browser close event is one situation that it won't.
Please, elaborate on this. Why would the call never run?
only two letters away from being an asset
I'll have to go back on what I said as closing the browser will run the code, but there are lots of cases where it won't. For instance, using the browsers back and forward buttons don't cause unload events (so if a user goes back a few pages before closing it won't run.....I don't think....), if the user has disconnected from tinternet, if the browser crashes, if you force quit the browser... It also depends on the browser, certainly IE has different ideas about when to call load events than Firefox. I'm not saying you can't use this method I'm just pointing out that it can't be 100% relied on (as anything client-side can't be)
-
I'll have to go back on what I said as closing the browser will run the code, but there are lots of cases where it won't. For instance, using the browsers back and forward buttons don't cause unload events (so if a user goes back a few pages before closing it won't run.....I don't think....), if the user has disconnected from tinternet, if the browser crashes, if you force quit the browser... It also depends on the browser, certainly IE has different ideas about when to call load events than Firefox. I'm not saying you can't use this method I'm just pointing out that it can't be 100% relied on (as anything client-side can't be)
badgrs wrote:
using the browsers back and forward buttons don't cause unload events
Yes, the event is fired.
badgrs wrote:
if the user has disconnected from tinternet, if the browser crashes, if you force quit the browser
Well of course you can't call a server-side method in this case :rolleyes:
badgrs wrote:
certainly IE has different ideas about when to call load events than Firefox.
As with many other things. Properly coding the application to handle different browsers is necessary in any professional, robust web application.
only two letters away from being an asset
-
badgrs wrote:
using the browsers back and forward buttons don't cause unload events
Yes, the event is fired.
badgrs wrote:
if the user has disconnected from tinternet, if the browser crashes, if you force quit the browser
Well of course you can't call a server-side method in this case :rolleyes:
badgrs wrote:
certainly IE has different ideas about when to call load events than Firefox.
As with many other things. Properly coding the application to handle different browsers is necessary in any professional, robust web application.
only two letters away from being an asset
Since your so adamant about it I had a little play around and I'm going to have to eat my words and say I'm wrong :-O I guess I didn't really give it much thought in the first place, just wanted to point out to the OP that javascript can't be relied upon....it seems we both know all about that though so no point in arguing technicalities.