开发者

Conditionally hide or show Aspx Menu Control Item

How do I hide or show a menu item based on a backend 开发者_如何学Ccondition?


You can remove that particular menu item as follows:

MenuItem mnuItem = mnu.FindItem(""); // Find particular item
mnu.Items.Remove(mnuItem);


Found a few links. Basically it looks like this will do the trick...

MyMenu.Items(1).Visible = False
  • http://www.vbforums.com/showthread.php?t=401836
  • http://forums.asp.net/t/1451884.aspx/1
  • http://msdn.microsoft.com/en-us/library/ms178429(VS.80).aspx

Any of those should give you what you need to hide menu items.


I think you need to remove it from the Menu:

protected void MyMenu_MenuItemDataBound(object sender, MenuEventArgs e)
    {
        if (e.Item.Text == "Menu Item To Remove")
        {
             MyMenu.Items.Remove(e.Item);
        }
    }


Try this:

Public Boolean Condition
{
   get { ... }
}


<asp:Menu ID="..." runat="server">
  <Items>
    <asp:MenuItem Text="..." Value="..." Visible="<%# this.Condition %>" />

    .....
  </Items>
</asp:Menu>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜