How To Avoid The “Are You Sure You Want To Navigate Away From This Page?” When Changes Committed? On Pagination Click Of Gridview In IE
My web page contains grid-view with many input fields.I want to give alert to user before moving to next tab. My script is working fine in Mozilla Firefox and chrome but in IE the
Solution 1:
just set the the value to null on pagination click
window.onbeforeunload = null;
UPDATE 1
try this one instead of your code:
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; /// make IE7, IE8 compitable
myEvent(chkevent, function (e) { // For >=IE7, Chrome, Firefox
var confirmationMessage = 'Are you sure to leave the page?'; // a space
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
UPDATE 2
after you use window.onbeforeunload = null; in your pagination control to rebind the alert in your update panel try this solution, it may help you with that issue:
$(document).ready(function () {
bindPageAlert();
});
function bindPageAlert()
{
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload';
myEvent(chkevent, function (e) { // For >=IE7, Chrome, Firefox
var confirmationMessage = 'Are you sure to leave the page?'; // a space
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(bindPageAlert);
Post a Comment for "How To Avoid The “Are You Sure You Want To Navigate Away From This Page?” When Changes Committed? On Pagination Click Of Gridview In IE"