ASP.NET web.sitemap 中是否可以有多个项目?
我有一个基于 Web.Sitemap 的 ASP.NET 菜单控件。 Web.Sitemap 不允许我在其根目录中拥有多个项目。但我需要我的菜单在其根目录中显示多个项目。是否可以?
我的站点地图是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="Menu" description="">
<siteMapNode url="~/Default.aspx" title="Public" description=""/>
<siteMapNode url="" title="Administration" description="">
<siteMapNode url="~/GeneralSettings.aspx" title="GeneralSettings" description=""/>
<siteMapNode url="~/LookupManagement.aspx" title="Lookup" description=""/>
<siteMapNode url="~/Administration.aspx" title="Database" description=""/>
</siteMapNode>
<siteMapNode url="~/AboutUs.aspx" title="Contact us" description="" />
</siteMapNode>
</siteMap>
I have an ASP.NET Menu control that works based on a Web.Sitemap. Web.Sitemap does not allow me to have more than one item in its root. But I need my menu show more than one item in its root. Is it possible?
My sitemap is like:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="Menu" description="">
<siteMapNode url="~/Default.aspx" title="Public" description=""/>
<siteMapNode url="" title="Administration" description="">
<siteMapNode url="~/GeneralSettings.aspx" title="GeneralSettings" description=""/>
<siteMapNode url="~/LookupManagement.aspx" title="Lookup" description=""/>
<siteMapNode url="~/Administration.aspx" title="Database" description=""/>
</siteMapNode>
<siteMapNode url="~/AboutUs.aspx" title="Contact us" description="" />
</siteMapNode>
</siteMap>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能在某处有一个 SiteMap 数据源 - 将“ShowStartingNode”属性更改为 false。
You probably have a SiteMap DataSource somewhere - change the "ShowStartingNode" attribute to be false.
根据您创建菜单的方式,您是否可以有一个“虚拟”根节点以及其下方的顶级项目,并从中渲染菜单,从而有效地忽略根节点?
Depending on how you're creating the menu, could you have a "dummy" root node, and your top-level items underneath this, and render the menu from these, effectively ignoring the root node?
我也遇到过类似的问题。我使用的分辨率取决于您绑定到 SiteMapDataSource 的控件:
选项 A:您使用的是 ASP.NET 菜单,在菜单属性中设置“StaticDisplayLevels=”2”`。< /p>
选项 B:如果您使用嵌套的Repeaters,或绑定到SiteMapDataSource的其他控件,则设置
ShowStartingNode="false" code> 如接受的答案所示,并手动对根页面进行编码,无论您希望它出现在菜单的其余部分中的任何位置。
I have had a similar problem. The resolution I used depends on what control you are binding to your SiteMapDataSource:
Option A: You are using asp.net menu, set 'StaticDisplayLevels="2"` in the menu properties.
Option B: if you are using nested Repeaters, or some other control that you bind to a SiteMapDataSource, then set
ShowStartingNode="false"
as the accepted answer shows and manually code the root page wherever you want it to appear in relation to the rest of your menu.