Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
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 at 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 at 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 at 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
0 Peter Leow 160
1 Mika Wendelius 156
2 Abhinav S 155
3 Sergey Alexandrovich Kryukov 115
4 TheRealSteveJudge 114
0 Sergey Alexandrovich Kryukov 8,593
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,436
4 Richard MacCutchan 2,417


Advertise | Privacy | Mobile
Web03 | 2.8.150123.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
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