Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:02:43+00:00 2026-06-14T22:02:43+00:00

I am trying to hide an Item from the Menu Items if a user

  • 0

I am trying to hide an Item from the Menu Items if a user is not in the Admin role. Here is the code that i am using in the code behind in my site master but the code is not hiding the Admin page in which i am trying to hide it. Here is the HTML markup for the master page:

 <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
                    IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Admin/Authors.aspx" Text="Admin" />
                        <asp:MenuItem NavigateUrl="~/Users/KCA_Summary.aspx" Text="KCA Summary" />
                        <asp:MenuItem NavigateUrl="~/Users/Details.aspx" Text="KCA Details" />

                    </Items>
                </asp:Menu>

and here is the code behind:

 Protected Sub Page_Load(sender As Object, e As EventArgs)
        If Not Roles.IsUserInRole("Admin") Then
            Dim menuItems As MenuItemCollection = NavigationMenu.Items
            Dim adminItem As New MenuItem()
            For Each menuItem As MenuItem In menuItems
                If menuItem.Text = "Admin" Then
                    adminItem = menuItem
                End If
            Next
            menuItems.Remove(adminItem)
        End If
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:02:45+00:00Added an answer on June 14, 2026 at 10:02 pm

    Probably the easiest way is to use a SiteMapProvider configured with SecurityTrimmingEnabled = true.

    The linked MSDN article references a lot of “How To” articles that will help you get started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to hide/unhide a submenu item (menumanager) from the context (popup menu)
I'm trying to concatenate a class selector using multiple variables that come from user
I'm trying to delete a li item using jquery, but its not working. Here's
I am trying to select the sub-menu item from a Wordpress default sidebar menu,
I am trying to hide a module from k2 item page. I have a
I'm trying to have some menu items slide down when a user hovers on
I'm trying to create combobox type interface so that user can select an item
Im using action bar compability library. Im trying to open the options menu from
I'm trying to hide the Settings area in CRM 2011 such that it is
i'm trying to hide/show some control on a page from Page_LoadComplete. If a put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.