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?