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 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Manas MohapatraRank #182 · 13.2K reputationPosted May 21, 2017, 1:40 AM EDT