简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM