Asp.net force save on detailsview / formview

When a user is using View Details or Form in Edit Mode and tries to leave the current page, I want to catch that and force any changes to be saved, as if the user had clicked the Update Link button. How can i do this?

+2


source to share


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







All Articles