带有web.sitemap的asp.net菜单 [英] asp.net menu with web.sitemap

查看:73
本文介绍了带有web.sitemap的asp.net菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿!

遇到一个关于asp.net菜单控件的业余,模棱两可的问题。

i制作了一个web.sitemap文件,如下所示:

hey !
ive encountered with a amateur , ambiguous issue about asp.net menu control .
i made a web.sitemap file as shown here :

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode title="main">
    <siteMapNode title="Home" description="Home" url="~/default.aspx">
    </siteMapNode>
    <siteMapNode title="Products" description="">
      <siteMapNode title="mobile" description="Our products" url="~/mobile.aspx">
        <siteMapNode title="web based"   url="~/webbased.aspx" />
        <siteMapNode title="windows"   url="~/windows.aspx" />
      </siteMapNode>
    </siteMapNode>
  </siteMapNode>
</siteMap>





我希望菜单控件水平显示...我写了这些简单的行:



and i want a menu control show it horizontally ... i wrote these simple lines :

<div id="Menu" style="padding :20px;">
       <asp:Menu ID="Menu1" Runat="server" 

            DataSourceID="SiteMapDataSource"

            Orientation="Horizontal">
      </asp:Menu>
      <asp:SiteMapDataSource ID="SiteMapDataSource" runat="server"/>
</div>





但它总是垂直显示项目,子菜单和父菜单如下所示:



but it always show items vertically and submenus and parent menus listed as below :

main
Home
Products
mobile
web based
windows





但它应该是这样的:



but it should be something like this :

Home Products▼ 





设计时间一切都如我所愿,但当我在任何浏览器上运行时,菜单显示我作为列表,菜单的项目和垂直列表中的子菜单......它根本没有向我显示水平!



问题是什么?有人可以帮助我吗?

感谢所有人花时间!



in design time everything is as my wish but when i run it on any browser , menu showed me items as list, menus and submenus in vertically list... it dnt show me horizontally at all !

whats the problem ... can anyone help me?
thanks all to spending time!

推荐答案

嗨!希望这能解决你的问题!!!我在当地的环境中检查了这个。它按预期工作..



Hi! Hope this solves your problem!!! i''ve checked this in my local env. it''s working as you expected..

<asp:Menu ID="Menu1" runat="server" orientation="Horizontal" StaticDisplayLevels="2" datasourceid="SiteMapDataSource1">
    </asp:Menu>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />





和站点地图文件



and in sitemap file

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="Home" description="Home">
    <siteMapNode title="Home" description="Home" url="~/default.aspx" />
    <siteMapNode title="Products" description="">
      <siteMapNode title="mobile" description="Our products" url="~/mobile.aspx">
        <siteMapNode title="web based"   url="~/webbased.aspx" />
        <siteMapNode title="windows"   url="~/windows.aspx" />
      </siteMapNode>
    </siteMapNode>
  </siteMapNode>
</siteMap>



参考: http:// msdn.microsoft.com/en-us/library/ecs0x9w5(v=vs.80).aspx [ ^ ]

如果你发现这个有用,请标记它!

~~ SATZ ~~


Ref:http://msdn.microsoft.com/en-us/library/ecs0x9w5(v=vs.80).aspx[^]
Mark it if you find this useful!!
~~SATZ~~


你在web.config中添加了提供者吗?...



Did you add provider?... in web.config???

<siteMap>
            <providers>
                <add name="MainWebSitemap" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
            </providers>
</siteMap>





并将其映射到



and mapped this to the

<asp:SiteMapDataSource

标签?


这篇关于带有web.sitemap的asp.net菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆