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 6964319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:35+00:00 2026-05-27T15:54:35+00:00

I am using asp:Menu to show menubar. The menu control uses sitemap as datasource.

  • 0

I am using asp:Menu to show menubar. The menu control uses sitemap as datasource. Now I want to delete some child nodes from sitemap node based on permission. I tried to manipulate Mennuitems but unable to delete that child node.

This is code to my menu control

<td class="TRMenu" valign="middle" align="left">
    <asp:Menu ID="menu" runat="server" CssClass="menu" EnableViewState="False" Orientation="Horizontal"
                DataSourceID="newSiteMap">
    </asp:Menu>
    <asp:SiteMapDataSource ID="newSiteMap" runat="server" ShowStartingNode="False" StartingNodeUrl="~/_PL/SPONSOR/Default.aspx" />
</td>

This is the code to my sitemap

<siteMapNode url="~/_PL/SPONSOR/Default.aspx" title="SPONSOR"  description="SPONSOR">
    <siteMapNode url="~/_PL/SPONSOR/Home.aspx" title="HOME"  description="HOME" />
    <siteMapNode url="~/_PL/SPONSOR/Default.aspx?0" title="Dash Board"  description="Dash Board" />
    <siteMapNode url="~/_PL/SPONSOR/SiteViewAll.aspx" title="Site Info."  description="Site Information" id="Site">
        <siteMapNode url="~/_PL/SPONSOR/Site.aspx" title="Add/Update Site Info."  description="Add/Update Site Information" id="Add"/>
        <siteMapNode url="~/_PL/SPONSOR/SiteViewAll.aspx?0" title="View Site Info."  description="View Site Information" />
    </siteMapNode>


    <siteMapNode url="~/_PL/SPONSOR/UserViewAll.aspx" title="User Info."  description="User Info" >
        <siteMapNode url="~/_PL/SPONSOR/User.aspx?New" title="Add/Update User Info."  description="Add/Update User Information" />
        <siteMapNode url="~/_PL/SPONSOR/UserViewHirerchical.aspx" title="View Hirerchical User"  description="View Hirerchical User Information" />
        <siteMapNode url="~/_PL/SPONSOR/UserViewAll.aspx?0" title="View User Info."  description="View User Information" />
    </siteMapNode>
    <!--<siteMapNode url="~/_PL/SPONSOR/CRFProtocol.aspx" title="CRF Protocol"  description="CRF Protocol" />-->
    <siteMapNode url="~/_PL/SPONSOR/eCRFDownload.aspx" title="CRF Download Forms"  description="CRF Download Forms" />
    <siteMapNode url="~/_PL/SPONSOR/LogSheet.aspx" title="Log Sheet"  description="Log Sheet" />
    <siteMapNode url="~/Default.aspx?logout=SPONSOR" title="Logout"  description="Logout" />
</siteMapNode>

I want to remove below node based on the permission

<siteMapNode url="~/_PL/SPONSOR/Site.aspx" title="Add/Update Site Info."  description="Add/Update Site Information" id="Add"/>

I have tried following method.

protected void Page_Unload(object sender, EventArgs e)
{

    foreach (MenuItem Item in menu.Items)
    {
        if (Item.Text.Contains("Site"))
        {
            string str = Item.ChildItems[0].Text;
            Item.ChildItems.RemoveAt(0);
        }

    }
}

I tried this in page load and prerender methods also but still the node is there when the page is loaded.

How can I remove it.?

  • 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-27T15:54:36+00:00Added an answer on May 27, 2026 at 3:54 pm

    I think right way to implement it is in the DataBound-Event of the menu-control:

    <asp:Menu ID="menu" runat="server" EnableViewState="False" Orientation="Horizontal" OnDataBound="Menu_DataBound" DataSourceID="newSiteMap">
    

    protected void Menu_DataBound(object sender, EventArgs e)
    {
        foreach (MenuItem item in menu.Items)
        {
            if (Item.Text.Contains("Site"))
            {
            string str = Item.ChildItems[0].Text;
            Item.ChildItems.RemoveAt(0);
            }
    
        }
    }
    

    Page.Unload-Event finds Items but seems not to be able to influence state of controls any more (probably because it is meant for other things).

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

Sidebar

Related Questions

I have a fairly simple ASP.NET 2.0 menu control using a sitemap file and
I am trying to populate an asp:Menu control using an XML file. I want
I am using an asp:menu control to display a menu. It uses a SiteMapDataSource
I am currently using an asp.net menu control to load from a table parent/child
I'm using an asp.net Menu (asp:Menu - the built-in one) and I want to
I'm using a ASP.NET menu control. I'd like the menu to look like this,
The site I'm working on is using a Databound asp:Menu control. When sending 1
I am using Asp.net menu control for the web site that I am currently
I'm using the asp:Menu control on an ASP.NET 4.0 Webforms page with table-free rendering
I'm using Visual Studio 2010 and ASP.NET 4.0 to render a Menu control as

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.