简体   繁体   English

如何在同一页面上呈现两个菜单?

[英]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. 我正在开发一个网站,它将具有我想使用ASP.NET的Menu控件生成的主要和辅助导航。 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. 两者都将基于web.sitemap - 来自root的主要,而secondary将是节点的一部分,具体取决于您所在的页面。

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. 更新:事实证明它只发生在我用于开发的Mono环境中,并且菜单在实际的.net服务器上完美运行。 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. 事实证明它只发生在我用于开发的Mono环境中,并且菜单在一个真正的.net服务器上完美运行。 I'll happily work around it knowing that it's just going to be an issue during development. 我很乐意解决它,因为它知道在开发过程中它会成为一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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