[RESOLVED]Give Warning if you move to another page while model is in middle of edit.

Is there a best practise for giving the user an warning if they try to move of a page while they are in a middle of an edit of a model entry.

In the old days with form’s we would just check the forum unload event for this state and through the message there.  Now in MVC how would one do this.

Thanks in Advance.


client browser has only the HTML in old and new.
the only option is handling the unload at client side.
we need to check the if at least on input is filled or you can let user leave

Hi Steve,

For this requirement, you could display warning message in the onbeforeunload event. (We can’t achieve that with MVC)

 <script type="text/javascript">
        window.onbeforeunload = OnBeforeUnLoad;
        function OnBeforeUnLoad () {
            return "All data that you have entered will be lost!";

For the jQuery, you could use unload function.

# unload()


Best Regards


Leave a Reply