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
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
That does work, thanks for the information; I must have just overlooked that before.
Hello MercerEng,
The client-side event model of UltraWebMenu is a bit different from what we are used to in default HTML controls. So, per the docs of UltraWebMenu, you can cancel the postback event by setting the CancelPostBack property of the menu instance to true. "return" statement will have no effect in this case, I am afraid.
Please, take a look at my code sample I sent for Pierre above - hopefully this will works fine for you as well.
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.
if(itemId == igmenu_getMenuById(menuId).getItems()[3].Id) //selected the delete option
return confirm('Are you sure you wish to delete this failure mode? After deletion, the information is unable to be recovered.');
Even after clicking cancel the postback continues and performs the deletion, though. Is there any way to make the confirmations work with the UltraWebMenu?