Is there a way to stop the user click on a menu item on the clientside? I tried with CancelPostBack and it seems not working.
My BLOCKED SCRIPT
function MasterMenu_ItemClick(menuId, itemId){
var MyCtl = recupereId("ctl00_ContentPlaceHolder1_btnApply"); try { if (!MyCtl.disabled){ var Messg = 'Update not done. Do you want to continue ?'; if (!confirm(Messg)){ igmenu_getMenuById(menuId).CancelPostBack = true; } } }catch (e) { //The btnApply not exist into this formalert("e.description is: " + e.description); }
var MyCtl = recupereId("ctl00_ContentPlaceHolder1_btnApply");
try {
if (!MyCtl.disabled){ var Messg = 'Update not done. Do you want to continue ?'; if (!confirm(Messg)){ igmenu_getMenuById(menuId).CancelPostBack = true; } }
var Messg = 'Update not done. Do you want to continue ?'; if (!confirm(Messg)){ igmenu_getMenuById(menuId).CancelPostBack = true; }
var Messg = 'Update not done. Do you want to continue ?';
if (!confirm(Messg)){
igmenu_getMenuById(menuId).CancelPostBack = true;
}
//The btnApply not exist into this formalert("e.description is: " + e.description);
//The btnApply not exist into this form
Hello Pierre,
I have something similar up and running really fine in my project. Where exactly the code above fails for you? Is it showing the confirm dialog window correctly? I have the gut feeling that maybe there is a javascript exception prior to executing the CancelPostBack logic and since everything is wrapped inside try/catch blocks the line with setting CancelPostBack is never reached. Also, using fixed ClientIDs in javascript may not always work, since ClientIDs change when additional controls are added on the page. You may try using
var MyCtl = document.getElementById("<%= btnApply.ClientID %>");
In any case, here is the code of my approach which works correctly for me:
<script type="text/javascript"> function itemClickHandler(menuID, itemID) { var menuInstance = igmenu_getMenuById(menuID); if (!confirm("Do you really want to postback?")) menuInstance.CancelPostBack = true; else menuInstance.CancelPostBack = false; } </script> <ignav:UltraWebMenu ID="UltraWebMenu1" runat="server" AutoPostBack="true"> <Items> <ignav:Item Text="Top Item"> <Items> <ignav:Item Text="Sub Menu Item"></ignav:Item> <ignav:Item Text="Sub Menu Item"></ignav:Item> </Items> </ignav:Item> <ignav:Item Text="Top Item"> <Items> <ignav:Item Text="Sub Menu Item"></ignav:Item> <ignav:Item Text="Sub Menu Item"></ignav:Item> </Items> </ignav:Item> </Items> <MenuClientSideEvents ItemClick="itemClickHandler"></MenuClientSideEvents> </ignav:UltraWebMenu>
Oh, btw, I am using version 7.3.20073.38
Hope this helps.
Thanks Rumen,
Excuse me for the delay, I was on other things.
You're right, that's work... if you don't set the link by theTargetURL property. When using the TargeUrl, the page change can't be stopped.
Anyway, I set my menu management differently.
Thanks again.
Pierre