How do I block menu buttons, when a form has not yet been saved, is it possible?

5

I'm new here. I'm starting in C # and I came across the following doubt:

I have a form, where I have not yet given a post yet, and I did not want to let the user leave this screen without saving.

What is the best practice for doing this?

    
asked by anonymous 30.09.2015 / 20:03

1 answer

3

The best alternative is to use jQuery :

$(window).bind('beforeunload', function(){
  return 'Are you sure you want to leave?';
});

Put this inside the <script> and </script> tags:

Here it explains more specifically the handler unload .

    
30.09.2015 / 20:27