user1877170
user1877170

Reputation:

Event in asp.net page

I want to execute a query when a user leave a page. Is there any event in asp.net page that happen when a user leave a page? thank you very much

Upvotes: 0

Views: 105

Answers (1)

Guffa
Guffa

Reputation: 700850

No, there is no server event when the user leaves a page, because the user isn't really "in" the page. The server sends a page to the browser, and then the browser displays it, and the server doesn't know what's happening in the browser.

You can catch the onbeforeunload in the browser, which is triggered when the browser is about to load a new page. Note however that it also fires for a postback, so you may have to keep track of what's happening to determine if the user is really going to a different page.

Note also that the onbeforeunnload event isn't standard, so it might not be supported in every browser.

Upvotes: 3

Related Questions