title: Remove child node from sitemap in master page
body: <p>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.</p>
  
  <p>This is code to my menu control</p>
  
  <pre><code>&lt;td class="TRMenu" valign="middle" align="left"&gt;
      &lt;asp:Menu ID="menu" runat="server" CssClass="menu" EnableViewState="False" Orientation="Horizontal"
                  DataSourceID="newSiteMap"&gt;
      &lt;/asp:Menu&gt;
      &lt;asp:SiteMapDataSource ID="newSiteMap" runat="server" ShowStartingNode="False" StartingNodeUrl="~/_PL/SPONSOR/Default.aspx" /&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>This is the code to my sitemap</p>
  
  <pre><code>&lt;siteMapNode url="~/_PL/SPONSOR/Default.aspx" title="SPONSOR"  description="SPONSOR"&gt;
      &lt;siteMapNode url="~/_PL/SPONSOR/Home.aspx" title="HOME"  description="HOME" /&gt;
      &lt;siteMapNode url="~/_PL/SPONSOR/Default.aspx?0" title="Dash Board"  description="Dash Board" /&gt;
      &lt;siteMapNode url="~/_PL/SPONSOR/SiteViewAll.aspx" title="Site Info."  description="Site Information" id="Site"&gt;
          &lt;siteMapNode url="~/_PL/SPONSOR/Site.aspx" title="Add/Update Site Info."  description="Add/Update Site Information" id="Add"/&gt;
          &lt;siteMapNode url="~/_PL/SPONSOR/SiteViewAll.aspx?0" title="View Site Info."  description="View Site Information" /&gt;
      &lt;/siteMapNode&gt;
  
  
      &lt;siteMapNode url="~/_PL/SPONSOR/UserViewAll.aspx" title="User Info."  description="User Info" &gt;
          &lt;siteMapNode url="~/_PL/SPONSOR/User.aspx?New" title="Add/Update User Info."  description="Add/Update User Information" /&gt;
          &lt;siteMapNode url="~/_PL/SPONSOR/UserViewHirerchical.aspx" title="View Hirerchical User"  description="View Hirerchical User Information" /&gt;
          &lt;siteMapNode url="~/_PL/SPONSOR/UserViewAll.aspx?0" title="View User Info."  description="View User Information" /&gt;
      &lt;/siteMapNode&gt;
      &lt;!--&lt;siteMapNode url="~/_PL/SPONSOR/CRFProtocol.aspx" title="CRF Protocol"  description="CRF Protocol" /&gt;--&gt;
      &lt;siteMapNode url="~/_PL/SPONSOR/eCRFDownload.aspx" title="CRF Download Forms"  description="CRF Download Forms" /&gt;
      &lt;siteMapNode url="~/_PL/SPONSOR/LogSheet.aspx" title="Log Sheet"  description="Log Sheet" /&gt;
      &lt;siteMapNode url="~/Default.aspx?logout=SPONSOR" title="Logout"  description="Logout" /&gt;
  &lt;/siteMapNode&gt;
  </code></pre>
  
  <p>I want to remove below node based on the permission</p>
  
  <pre><code>&lt;siteMapNode url="~/_PL/SPONSOR/Site.aspx" title="Add/Update Site Info."  description="Add/Update Site Information" id="Add"/&gt;
  </code></pre>
  
  <p>I have tried following method.</p>
  
  <pre><code>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);
          }
  
      }
  }
  </code></pre>
  
  <p>I tried this in page load and prerender methods also but still the node is there when the page is loaded.</p>
  
  <p>How can I remove it.?</p>