views:

15

answers:

2

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?

A: 
<siteMapNode url="" title="Fruit"  description="">
  <siteMapNode url="~/Apple.aspx" title="Apple"/>
  <siteMapNode url="~/Orange.aspx" title="Orange"/>
  <siteMapNode url="~/Strawberry.aspx" title="Strawberry"/>
</siteMapNode>

Like wise with Colors

Baharanji
I already tried this, but when I do this the whole Fruit menu disappears.
User
A: 

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;
    }
}
User