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

  • Home
  • SEARCH
  • 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 6093171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:46+00:00 2026-05-23T12:31:46+00:00

I want to hide the Admin Panel menu item from visitor, without going into

  • 0

I want to hide the “Admin Panel” menu item from visitor, without going into the Role approach.

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title="Nav"  description="">
        <siteMapNode url="~/Default.aspx" title="Home"  description=""></siteMapNode>
        <siteMapNode url="~/About.aspx" title="About"  description=""></siteMapNode>
        <siteMapNode url="" title="Admin Panel"  description="">
          <siteMapNode url="~/Admin/AddPosts.aspx" title="Add Posts"  description=""></siteMapNode>
          <siteMapNode url="~/Admin/EditPosts.aspx" title="Edit Posts"  description=""></siteMapNode>
          <siteMapNode url="~/Admin/ApproveComments.aspx" title="Approve Comments"  description=""></siteMapNode>
        </siteMapNode>
    </siteMapNode>
</siteMap>

master page

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
    {
        System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
        SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;

        System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);

        if (mapNode.Title == "Admin Panel")
        {
            System.Web.UI.WebControls.MenuItem parent = e.Item.Parent;
            if (parent != null)
            {
                parent.ChildItems.Remove(e.Item);
            }
        }
    }
}

markup

    <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" 
        Orientation="Horizontal" onmenuitemdatabound="Menu1_MenuItemDataBound">
    </asp:Menu>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" 
        ShowStartingNode="False" />

I tired the code above, but it is not working. It looks like, the parent for “Admin Panel” is null. But i don’t know how to modify it to make it work.

I also tried a simply version:

Menu1.Items.RemoveAt(2);

Not sure why it gave me index out of bound error. The Admin Panel item is really the 3rd item in Menu1 though.

Any help would be appreciated.

  • 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-05-23T12:31:47+00:00Added an answer on May 23, 2026 at 12:31 pm

    Could do this 2 ways:

    MarkUp:

    <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
                    EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" 
                    DataSourceID="SiteMapDataSource1" 
                    onmenuitemdatabound="NavigationMenu_MenuItemDataBound">
    </asp:Menu>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
    

    Code:

    protected void NavigationMenu_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        System.Web.UI.WebControls.Menu menu = (System.Web.UI.WebControls.Menu)sender;
        SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;
    
        if (mapNode.Title == "Admin Panel")
        {            
            System.Web.UI.WebControls.MenuItem itemToRemove = menu.FindItem(mapNode.Title);
            menu.Items.Remove(itemToRemove);
        }
    }
    

    Markup:

    <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" 
                    EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" 
                    DataSourceID="SiteMapDataSource1" ondatabound="NavigationMenu_DataBound" >
    </asp:Menu>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
    

    Code:

    protected void NavigationMenu_DataBound(object sender, EventArgs e)
    {
        ((System.Web.UI.WebControls.Menu)sender).Items.RemoveAt(2);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to hide the selected item from the opened WPF combo box, basically
I want to hide all mysql error messages without using mysql_error() . Are there
I want to hide all the descendents of the ul for my tree menu
I want to be able to output data from PowerShell without any column headings.
I just want to hide/show the inlines in admin interface like providing classes': ['collapse']}).
I want to remove/igonre/hide whichever is better .rb~ and .# files such as .#admin.rb.1.2
I want to hide the keyboard after typing the content into the UITextView but
I want to hide soft keyboard from my android application while start the application.
I want to hide the Next button on my ASP.NET Wizard control using JavaScript.
I want to hide the cursor when showing a webpage that is meant to

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.