1
我使用asp:Menu來顯示菜單欄。菜單控件使用站點地圖作爲數據源。現在我想根據權限從站點地圖節點中刪除一些子節點。我試圖操作Mennuitems,但無法刪除該子節點。在主頁面中從站點地圖中刪除子節點
這是我的菜單控制
<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>
代碼這是代碼到我的網站地圖
<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>
我想根據許可
<siteMapNode url="~/_PL/SPONSOR/Site.aspx" title="Add/Update Site Info." description="Add/Update Site Information" id="Add"/>
我刪除以下節點嘗試過以下方法。
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);
}
}
}
我在頁面加載和預渲染方法中也嘗試過這種方法,但當頁面加載時仍然存在節點。
我該如何刪除它。