Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
WebMenu - Stopping the click on clientside (NA-7.3)
posted

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 form

alert("e.description is: " + e.description);

}

}

Parents
  • 28464
    posted

    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.

Reply Children
No Data