I am using Ajax tabcontainer. i want to restrict the onbeforeunload event being fired on Ajax TabContainer. On click of one of the tab of TabContainer i am getting the alert/confirm message box which i have return in Onbeforeunload function.
The alert occurs because on tab click i have written C# code so postback occurs.
$('a').click(function() {
window.onbeforeunload = null;
});
window.onbeforeunload = function() {
return 'Pending changes will be lost unless they are saved first.'
'Are you sure you want to leave this page?';
};Thanks in advance
Sravan KumarPosted Feb 2, 2015, 10:38 AM
I am exactly struck at the same situation.
Thanks in advance
Iftikar HussainPosted Aug 13, 2013, 11:29 AM
Try like this
Regards,
Iftikar
Abhishek JainPosted Aug 13, 2013, 9:38 AM
So what i am proposing will not look so good but that is how you have to handle it
var isTabClicked = false;
$('a').click(function() {
isTabClicked = true;
});
window.onbeforeunload = function() {
if(!isTabClicked)
{
return 'Pending changes will be lost unless they are saved first.'
'Are you sure you want to leave this page?';
}
};