Click here to Skip to main content
13,248,562 members (72,561 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
hi ............

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

<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 4-Jun-12 21:41pm
Comments
Ganeshcse 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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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;
}
}
}
  Permalink  
Comments
Ganeshcse 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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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!
  Permalink  
Comments
Marcus Kramer 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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100