让我的ASP菜单控件忽略XML节点

时间:2011-03-10 22:43:05

标签: asp.net

我正在尝试使用XML文件填充asp:Menu控件。我希望菜单节点在静态视图中横向显示控件,并让SubMenu节点从它们动态扩展。

问题是我不想让Top节点显示出来。现在我的菜单显示了Top节点,其他所有内容都是动态展开的。如何告诉它忽略菜单的Top节点?

<div class="clear hideSkiplink">
    <asp:XmlDataSource DataFile="~/menu.xml" ID="menuDataSource" runat="server" />
    <asp:Menu ID="NavigationMenu"  StaticDisplayLevels="1" MaximumDynamicDisplayLevels="5" DataSourceID="menuDataSource" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
         <DataBindings>
              <asp:MenuItemBinding DataMember="Menu" TextField="Text" NavigateUrlField="url" />
              <asp:MenuItemBinding DataMember="SubMenu" TextField="Text" NavigateUrlField="url" />
         </DataBindings>
    </asp:Menu>
</div>

<?xml version="1.0" encoding="utf-8" ?>

<Top>
    <Menu text="Home" url="~/default.aspx"></Menu>
    <Menu text="Ladies Styles" url="~/Products/LadiesStyles.aspx">
        <SubMenu text="Rylee" url="~/Products/Rylee.aspx"></SubMenu>
        <SubMenu text="Cameron" url="~/Products/Cameron.aspx"></SubMenu>
        <SubMenu text="Sadie" url="~/Products/Sadie.aspx"></SubMenu>
        <SubMenu text="Alanna" url="~/Products/Alanna.aspx"></SubMenu>
        <SubMenu text="Kelsey" url="~/Products/Kelsey.aspx"></SubMenu>
        <SubMenu text="Paige" url="~/Products/Paige.aspx"></SubMenu>
        <SubMenu text="Haylie" url="~/Products/Haylie.aspx"></SubMenu>
        <SubMenu text="Zoey" url="~/Products/Zoey.aspx"></SubMenu>
    </Menu>
    <Menu text="Traditional Styles"  url="MenuFromXml.aspx">
        <SubMenu text="Set In Styles" url="MenuFromXml.aspx">
            <SubMenu text="Standard" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Brock" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Trevin" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Gavin" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Landon" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Carson" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Hillary" url="MenuFromXml.aspx"></SubMenu>
        </SubMenu>
        <SubMenu text="Raglan Styles" url="MenuFromXml.aspx">
            <SubMenu text="Raglan" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Zachary" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Jacoby" url="MenuFromXml.aspx"></SubMenu>
            <SubMenu text="Keller" url="MenuFromXml.aspx"></SubMenu>
        </SubMenu>
    </Menu>
    <Menu text="Kids Styles" url="~/Products/KidsStyles.aspx">
        <SubMenu text="Brock" url="~/Products/KidsBrock.aspx"></SubMenu>
        <SubMenu text="Rylee" url="~/Products/KidsRylee.aspx"></SubMenu>
    </Menu>
    <Menu text="Patches and Accessories" url="~/Products/PatchAccessories.aspx">
        <SubMenu text="Name Patches" url="~/Products/Rylee.aspx"></SubMenu>
        <SubMenu text="Mascot Patches" url="~/Products/Cameron.aspx"></SubMenu>
        <SubMenu text="State Patches" url="~/Products/Sadie.aspx"></SubMenu>
        <SubMenu text="Hoods" url="~/Products/Alanna.aspx"></SubMenu>
        <SubMenu text="Rhinestones" url="~/Products/Kelsey.aspx"></SubMenu>
    </Menu>
    <Menu text="Color Charts" url="~/Products/ColorCharts.aspx">
        <SubMenu text="Wool Colors" url="~/Products/KidsBrock.aspx"></SubMenu>
        <SubMenu text="Leather Colors" url="~/Products/KidsRylee.aspx"></SubMenu>
        <SubMenu text="Lining Fabrics" url="~/Products/KidsRylee.aspx"></SubMenu>
    </Menu>
    <Menu text="Size Charts" url="MenuFromXml.aspx"></Menu>
</Top>

1 个答案:

答案 0 :(得分:2)

使用SiteMapDataSource并将ShowStartingNode设置为false。