Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 16, 2012 10:10 AM by CasualTrash
Jan 02, 2008 02:59 PM|LINK
When setting the staticdisplaylevels = "2" w/ orientation="Horizontal" it places all menu items on one row, not 2 rows. Is it possible to use the Asp.Net Menu control to display the menu in 2 rows or do we need to use another solution?
ASP.NET 2.0 Menu
Jan 02, 2008 03:41 PM|LINK
Are you sure about this? This is supposed to work, so maybe the items only appear to be on the same row visually. Check the html source code, does it have two rows? The staticdisplaylevel property indicates how many levels are fully displayed, deeper menu
levels will show according to the selected menu item (and the dynamicdisplaylevel property).
Jan 02, 2008 05:24 PM|LINK
When you say 2 rows, are you looking for a menu like
this. If yes, then it can be implemented using pure CSS. The tutorials to do that is
Lastly, if you want to use the CSS menu and at the same time render it in your asp.net application as a CSS menu, then you
might need to also use CSS Control Adapters. Scott Gu has an excellent post
Jan 02, 2008 06:10 PM|LINK
My intention was not to have to manage the clicked/ not clicked menu items and use the
StaticHoverStyle-BackColor properties of the Menu control. I have previously built this functionality with a repeater control but, was hoping for a solution which is easier to manage and with less coding with the standard Menu control.
Unless anyone can shed light on using the Menu control, I'll continue using the custom menu. Thanks..
Jan 04, 2008 04:49 AM|LINK
Base on your description, do you want to make the Submenu item horizontal?
The ASP.NET 2.0 Menu Control doesn't support Horizontal fly-outs(please check the
dannychen post in this thread:
Maybe, you can try to consider to use the third party control instead, the third party control you can check this link:
Hope it helps.
Happy new year!
Nov 16, 2012 10:10 AM|LINK
A few years later but I post here a solution in case that somebody has the same problem.
You can achieve it with two menus and two sitemapdatasources. In the first menu you display only the first level and in the second menu only the second level, you can control the menu level in the sitemapdatasource by setting the statingnodeoffset property
to the desired level, here the code:
<asp:SiteMapDataSource ID="Sitemapdatasource1" runat="server" ShowStartingNode="False" />
<asp:Menu ID="Menu1" runat="server"
<asp:SiteMapDataSource ID="Sitemapdatasource2" runat="server" ShowStartingNode="False" StartingNodeOffset="1" />
<asp:Menu ID="Menu2" runat="server"
There is an event handler on the item bound event of the first menu, this is for selecting the right menu item when an item in the sub menu is selected, yes when you selected an item in the sub menu the main menu loses the selected item. To select the right menu item you have to get the current node from the sitemap and determine if the item is in the menu path. I written an extension method to do it:
public static bool IsInMenuPath(this SiteMapNode thisnode, SiteMapNode node)
var temp = node;
while (temp != null && temp != thisnode) temp = temp.ParentNode;
return temp != null;
protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
e.Item.Selected = ((SiteMapNode)e.Item.DataItem).IsInMenuPath(SiteMap.CurrentNode);
ASP.NET 2.0 Menu