Hi,
I have the following code on my page:
OnTextBoxValueChanged is the handler for RadTextBox's corresponding client event.
if user changes text in textbox, then moves focus to any other element and then presses 'close tab' in browser - confirmation window appears. This is correct. But the problem appears when user changes text and then immediately presses 'close tab'. In this case onbeforeunload event fires before onvaluechanged and isDirty variable has incorrect value (false) in onbeforeunload handler.
Am I doing something wrong or is there a workaround for my case?
Thanks,
Andrey
I have the following code on my page:
var
isDirty =
false
;
function
OnTextBoxValueChanged(sender, args)
{
isDirty =
true
;
}
window.onbeforeunload =
function
()
{
if
(isDirty)
{
return
'You have unsaved changes on the form.'
;
}
}
OnTextBoxValueChanged is the handler for RadTextBox's corresponding client event.
if user changes text in textbox, then moves focus to any other element and then presses 'close tab' in browser - confirmation window appears. This is correct. But the problem appears when user changes text and then immediately presses 'close tab'. In this case onbeforeunload event fires before onvaluechanged and isDirty variable has incorrect value (false) in onbeforeunload handler.
Am I doing something wrong or is there a workaround for my case?
Thanks,
Andrey