I want to show message before leave the same page but prevent it on button clcik and drop down selected index changed below is coe.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
window.onbeforeunload = function (event) {
var message = 'Important: Please click on \'Save\' button to leave this page.';
if (typeof event == 'undefined') {
event = window.event;
}
if (event) {
event.returnValue = message;
}
return message;
};
$(function () {
$("#<%= ddlbranch.ClientID %>").change(); (function () {
window.onbeforeunload = null;
});
$("#<%= Button1.ClientID %>").click(); (function () {
window.onbeforeunload = null;
});
});
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Manas MohapatraPosted May 21, 2017, 5:40 AM