Search code examples
asp.netmenuaspmenuaspmenu-control

How to make menu's second level static


I am using an asp:menu control to display a menu. It uses a SiteMapDataSource for it's data. I would like to see make the top two level static and the other levels appear if the mouse hover's over them.

Here is the code.

<asp:Menu ID="Menu1" runat="server" BackColor="#000000" DataSourceID="SiteMapDataSource"  DynamicHorizontalOffset="0" Font-Names="Verdana" Font-Size="Small" ForeColor="#ffffff">
<StaticSelectedStyle BackColor="#000000" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#284E98" ForeColor="#FFFFFF" />
<DynamicMenuStyle BackColor="#000000" />
<DynamicSelectedStyle BackColor="#000000" BorderStyle="Double" />
<DynamicMenuItemStyle BackColor="#000000" HorizontalPadding="5px" 
         VerticalPadding="2px" />
<StaticHoverStyle BackColor="#000000" ForeColor="White" />
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource" runat="server" />

Is there any way to do such a thing?


Solution

  • Try setting StaticDisplayLevels

    <asp:Menu ID="Menu1" StaticDisplayLevels="2" runat="server" BackColor="#000000" DataSourceID="SiteMapDataSource"  DynamicHorizontalOffset="0" Font-Names="Verdana" Font-Size="Small" ForeColor="#ffffff">