0

I have several pages in my ASP.Net application and several Hyperlinks in pages.

Is there anyway I can alert users if he/she tries to navigate without saving data?

Please help

NakedBrunch
  • 48,713
  • 13
  • 73
  • 98
acadia
  • 2,619
  • 18
  • 55
  • 72
  • Does this answer your question? [Warn user before leaving web page with unsaved changes](/q/7317273/90527) – outis Oct 17 '22 at 21:00

1 Answers1

1

Take a look at the JavaScript onbeforeunload event.

As a user fills in form fields, upon blur from any of the fields, set a HasData variable to true. Using the Onbeforeuload event, you can check to see if HasData is true. If so, you can prompt the user to confirm that they want to leave without saving.

NakedBrunch
  • 48,713
  • 13
  • 73
  • 98