0

I am using the window.onbeforeunload() function to warn the user about any unsaved changes when he tries to navigate away from the page. Everything works fine, sans one scenario.

If there is a control with AutoPostback = true (like RadioButtonList, Textbox with CalendarExtender etc.), and the user chooses 'Stay on the page', I get an unspecified JavaScript error. And the previous value of the control also doesn't persist. If he chooses to 'Leave the page', all works well. However, the other scenario doesn't.

Searched extensively on SO as well as other places for this issue, including this article from 4guysfromrolla. But nothing comes up with a solution for this. I have managed to form a workaround for this by using a simple JavaScript confirm and a hidden button, but I'd like to know if my problem can be solved on its own, or is this another IE quirk?

CopyPasteDev
  • 196
  • 1
  • 14
  • Does this help you: http://stackoverflow.com/questions/1235024/asp-net-jquery-dirty-forms-and-window-onbeforeunload ? – Abhitalks May 13 '14 at 10:35
  • And this: http://stackoverflow.com/questions/3290758/dropdownlist-not-firing-onbeforeunload-when-autopostback-true ? – Abhitalks May 13 '14 at 10:35
  • @abhitalks, I don't think the above two posts talk about the issue I'm facing. The onbeforeunload fires when it should, but for controls with AutoPostback = true, it throws this error when user wants to stay on the page. – CopyPasteDev May 13 '14 at 10:40

0 Answers0