Click here to Skip to main content
15,936,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ............

i want disabled menun control on button click event but it not working my code is

XML
<head runat="server">
    <title></title>
    <script type ="text/javascript" >
        function hideMenu() {
            alert("in");
            document.getElementById('Menu1').Enabled = false;
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"  Enabled = false >
            <Items>
                <asp:MenuItem Text="New Item" Value="New Item">
                    <asp:MenuItem Text="New Item" Value="New Item">
                        <asp:MenuItem Text="New Item" Value="New Item"></asp:MenuItem>
                    </asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="New Item" Value="New Item">
                    <asp:MenuItem Text="New Item" Value="New Item"></asp:MenuItem>
                </asp:MenuItem>
                <asp:MenuItem Text="New Item" Value="New Item"></asp:MenuItem>
            </Items>
        </asp:Menu>
        <input id="Button1" type="button" value="button" onclick="hideMenu();"  />
    </div>
    </form>
</body>
</html>
Posted
Comments
Ganesh KP 1-Oct-12 1:46am    
How about if we want to disable only one menu item in asp menu using javascript. Please Post the answer here.

Thanks
Ganesh

I know this is an old post, but you need to change:

document.getElementById('Menu1').Enabled = false;

to

document.getElementById('Menu1').disabled = true;



Hope this helps!
 
Share this answer
 
Comments
fjdiewornncalwe 25-Feb-13 13:55pm    
It is an old post, and the answer you gave already exists in Solution 1. Please read the existing solutions before posting duplicates. Cheers and welcome to CP.
Below you find coding of hideMenu() function that is working properly as per your need.

function hideMenu(){
var menu=$get('<%= Menu1.ClientID %>');
if(menu != null){
var count = menu.all.length;
for(var i = 0;i < count; i++){
menu.all[i].disabled=true;
}
}
}
 
Share this answer
 
Comments
Ganesh KP 3-Oct-12 4:29am    
I have pasted the code in my doc.ready function but doesn't work. I have tried also calling that function onclientclick for menu item even then also not works. So Please tell me what to do and where to call exactly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900