BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Hayssam Hassan,
Thanks for using Syncfusion products.
To avoid showing alert on clicking menuitem or button we have maintained a flag variable in "Menu" control’s cliendSideevent "ClientSideOnItemSelect"
and "Button" control’s cliendsideevent "OnClientClick" .Therefore, alert will be shown only if the flag is false.
Please refer the following code snippet
<code>
[JavaScript]
<script type="text/javascript">
var event = 0; //falg variable
function buttonClick() {
event = 1; //set falg true
}
function menuClick() {
event = 1; //set flag true
}
var warnMessage = "Are sure you want to close Application?";
window.onbeforeunload = function () {
if (event === 0) {
return warnMessage
}
};
$(document).ready(function () {
$('a').click(function () { window.onbeforeunload = null; });
$('form').submit(function () { window.onbeforeunload = null; });
});
</script>
[Aspx]
<syncfusion:Menu ID="Menu" runat="server" ClientSideOnItemSelect="menuClick()">
<asp:Button ID="btn" runat="server" Text="Button Sample" OnClientClick="return buttonClick()" />
</code>
We have also prepared a simple sample to showcase this behavior and the sample can be downloaded from the link given below
Kindly try the attached sample and let us know if this helps.
Thanks & Regards
Sunil Prabakar C