I’m trying to create an asp menu for a website. The site will have 2 levels of user Master users (which will have more options) and Sub users which will have limited menu options.
I was wonder does anyone knows if a way to hide menu items? I’ve tried google but I can’t really find much.
Here’s the Asp code
<asp:Menu id="MainMenu" runat="server" StaticDisplayLevels="1" Orientation="Horizontal" >
<Items>
<asp:MenuItem Text="Setup" Value="">
<asp:MenuItem ID="DepoAccount" Text="Depo Account Details" Value="" NavigateUrl="~/AccountManagment.aspx"></asp:MenuItem>
<asp:MenuItem Text="User Accounts" Value="" NavigateUrl="~/ImplantParameters.aspx"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Actions" Value="">
<asp:MenuItem Text="View Consignments" Value="" NavigateUrl="~/Consignements.aspx"></asp:MenuItem>
<asp:MenuItem Text="Add Consignments" Value="" NavigateUrl="~/Consignements.aspx"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Utitlies" Value="">
<asp:MenuItem Text="Export" Value="" NavigateUrl="~/ImplantParameters.aspx"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Reports" Value="">
<asp:MenuItem Text="Manifest" Value="" NavigateUrl="~/ImplantParameters.aspx"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
I have worked out how to hide the whole menu when the user is not logged in
MainMenu.Visible = false
Any pointers would be greatly appreciated.
You’re looking for ASP.NET’s Security Trimming feature.
You should move your static menu items into an XML SiteMap file, and set
EnableSecurityTrimmingon the sitemap to true.