Execute some codes when closing an Asp.net page
问题 I want to delete a row in a Database table when a user closes an .aspx page. How could I do it? I know how to delete a row in a Database table but I don't know how to do it when a user leaves an .aspx page? 回答1: You can bind an ajax call to the "beforeunload" page html event. Just make sure to call ajax with async false, otherwise the page will be close before the code to delete the row actually runs. I'm assuming you are using jQuery for the ajax call. For example, in html: <body