Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to hide or invisible sub menu from menu strip in master page?
.
i have menu strip, so admin can view all menus and sub-menus,
another one is user, but he/she can't view all sub-menus from menu,
so how can i prevent user to prohibit from this ??
Posted
Comments
Samatha Reddy G 7-Oct-14 7:58am    
can you please post your code?
Madhuri Gamane 7-Oct-14 8:10am    
Code ??
Which Code ?
i just have menu bar and sub menus in that menu,
so i just want to invisible that on user change on logon..
Richard Deeming 7-Oct-14 8:17am    
There are many different ways to implement menus in ASP.NET - if you don't tell us which you're using, and you don't post your code, then we can't help you.
Madhuri Gamane 7-Oct-14 8:23am    
it is not that matter, i haven't code yet, i am get confused, what code to do? that's why i asked a question..
Richard Deeming 7-Oct-14 8:25am    
You presumably have some kind of markup on your page which defines the menu bar? That counts as "code".

 
Share this answer
 
Master Page :

XML
<asp:Menu ID="Menu_id" runat="server">
           <Items>
               <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
               <asp:MenuItem Text="Aboutus" Value="Aboutus"></asp:MenuItem>
               <asp:MenuItem Text="Services" Value="Services">
                   <asp:MenuItem Text="Microsoft" Value="Microsoft"></asp:MenuItem>
                   <asp:MenuItem Text="Java" Value="Java"></asp:MenuItem>
                   <asp:MenuItem Text="Oracle" Value="Oracle"></asp:MenuItem>
                   <asp:MenuItem Text="SAP" Value="SAP"></asp:MenuItem>
               </asp:MenuItem>
               <asp:MenuItem Text="Contactus" Value="Contactus"></asp:MenuItem>
           </Items>

       </asp:Menu>


Login page :

Menu obj_Menu = (Menu)Master.FindControl("Menu_id");



obj_Menu.Items.RemoveAt(2);  // this will remove parent Item(all Child Items also cleared)

obj_Menu.Items[2].ChildItems.RemoveAt(1);  // this will remove the first menuitem in Child Items

obj_Menu.Items[2].ChildItems[1].ChildItems.RemoveAt(1); // this will remove the first menu item in sub child items
 
Share this answer
 

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