带有 .sitemap 文件的 ASP.Net 菜单控件
我在将站点地图文件绑定到 ASP.Net 中的菜单控件方面没有丰富的经验,并且想看看这是否可行(无需大量自定义管道)。
我正在使用 CSS 友好适配器 来获得干净的标记。我已经准备好 CSS 来创建水平导航,其中顶部栏代表主导航,下部栏代表子导航。
本质上我想转换此站点地图文件:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode url="~/Page1.aspx" title="Page1" description="">
<siteMapNode url="~/SubPage1_1.aspx" title="Sub Page 1.1" description="" />
<siteMapNode url="~/SubPage1_2.aspx" title="Sub Page 1.2" description="" />
</siteMapNode>
<siteMapNode url="~/Page2.aspx" title="Page2" description="">
<siteMapNode url="~/SubPage2_1.aspx" title="Sub Page 2.1" description="" />
<siteMapNode url="~/SubPage2_2.aspx" title="Sub Page 2.2" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
转换为此标记:
<div class="nav" >
<ul class="fixed">
<li><a href="Page1.aspx" class="active">Page 1</a></li>
<li><a href="Page2.aspx">Page 2</a></li>
</ul>
</div><!-- end .nav -->
<div class="subnav" >
<ul class="fixed">
<li><a href="SubPage1_1.aspx" class="active">Page 1.1</a></li>
<li><a href="SubPage1_2.aspx">Page 1.2</a></li>
</ul>
</div><!-- end .subnav -->
其中子导航绑定到站点地图中主导航节点的子节点。
我期望这会很简单是不是错了;)
I don't have tons of experience with binding sitemap files to the menu control in ASP.Net and wanted to see if this was possible (without a lot custom plumbing).
I am using the CSS Friendly Adapters to get clean markup. I have the CSS already prepared to create horizontal navigation, where the top bar represents the main navigation, and the lower bar represents sub-navigation.
Essentially I want to transform this sitemap file:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home" description="">
<siteMapNode url="~/Page1.aspx" title="Page1" description="">
<siteMapNode url="~/SubPage1_1.aspx" title="Sub Page 1.1" description="" />
<siteMapNode url="~/SubPage1_2.aspx" title="Sub Page 1.2" description="" />
</siteMapNode>
<siteMapNode url="~/Page2.aspx" title="Page2" description="">
<siteMapNode url="~/SubPage2_1.aspx" title="Sub Page 2.1" description="" />
<siteMapNode url="~/SubPage2_2.aspx" title="Sub Page 2.2" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
Into this markup:
<div class="nav" >
<ul class="fixed">
<li><a href="Page1.aspx" class="active">Page 1</a></li>
<li><a href="Page2.aspx">Page 2</a></li>
</ul>
</div><!-- end .nav -->
<div class="subnav" >
<ul class="fixed">
<li><a href="SubPage1_1.aspx" class="active">Page 1.1</a></li>
<li><a href="SubPage1_2.aspx">Page 1.2</a></li>
</ul>
</div><!-- end .subnav -->
Where the sub-navigation is bound to the child nodes of the main navigation node in the sitemap.
Is it wrong of me to expect this will be simple ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,解决方案实际上非常简单。
通过使用两个 SiteMapDataSourceControls,以及设置第二个的 StartingNodeOffset=1,那么使用两个中继器就可以有效地实现两层导航的方式。
So it turns out that the solution is in fact very simple.
By using two SiteMapDataSourceControls, and setting the second one's StartingNodeOffset = 1, then you can effectively achieve the two layered navigation approach by using two repeaters.