简体   繁体   中英

How to render two menus on same page?

I'm working on a site that will have a primary and secondary navigation that I'd like to generate using ASP.NET's Menu controls. Both will be based on the web.sitemap - the primary from the root, and the secondary will be a section of nodes depending on which page you're on.

The first go of adding a menu worked perfectly:

<form runat="server">
        <asp:SiteMapDataSource id="nav1" runat="server" StartingNodeUrl="~/en/default.aspx" ShowStartingNode="False" />
        <asp:Menu runat="server" DataSourceId="nav1" disappearafter="1000" MaximumDynamicDisplayLevels="1" />           
</form>

However, after adding a second menu control, while the first menu still works as expected, the second menu's the first dropdown never disappears and any other dropdowns don't open at all:

<form runat="server">
        <asp:SiteMapDataSource id="nav1" runat="server" StartingNodeUrl="~/default.aspx" ShowStartingNode="False" />
        <asp:Menu runat="server" DataSourceId="nav1" MaximumDynamicDisplayLevels="1" />

        <asp:SiteMapDataSource id="nav2" runat="server" StartingNodeUrl="~/section/default.aspx"/>
        <asp:Menu runat="server" DataSourceId="nav2" MaximumDynamicDisplayLevels="1" />         
</form>

UPDATE: Turns out it's only happening in the Mono environment I'm using for development, and the menus are working perfectly on an actual .net server. I'll happily work around it knowing that it's just going to be an issue during development.

Turns out it's only happening in the Mono environment I'm using for development, and the menus are working perfectly on an actual .net server. I'll happily work around it knowing that it's just going to be an issue during development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM