Asp.net force save on detailsview / formview
1 answer
You cannot do this reliably. Consider the scenario if their computer crashes at all, or if they pop out the power cord. There are so many ways that a user can leave a page.
However, you could set several guarantees. On any link on the page, you can hook up events to save before they go away. You can also try doing a rescue after every change in the control focus, perhaps.
Another thing you can do is hook up to the window.onbeforeunload event and give them a confirmation asking if they are sure they will want to leave the page like SO when you have an unsaved response. But there is nothing you can do about this event to force the save.
+3
source to share