I have an asp:Menu control driven by a web.sitemap file.
For example, the menu is like:
Fruit
- Apple
- Orange
- Strawberry
Color
- Blue
- Red
- Yellow
In the sitemap, the specific fruits are children of the "Fruit" siteMapNode (likewise for the colors) The menu is setup as dynamic so Fruit and Color are static and the specific fruits and colors show up in the popup/flyout menu. The parent items are just for categorization purposes; there's no "Fruit" page.
How do I make it so "Fruit" and "Color" are NOT links?
I ended up adding an event handler to handle this. It's not really ideal but it does the job.
<asp:Menu ID="MyMenu" runat="server" DataSourceID="MyDataSource"
OnMenuItemDataBound="MyMenu_MenuItemDataBound">
...
protected void MyMenu_MenuItemDataBound(object sender, MenuEventArgs e)
{
SiteMapNode node = (SiteMapNode)e.Item.DataItem;
if (node.ChildNodes.Count != 0)
{
e.Item.Selectable = false;
}
}