ASP.net MenuBar

时间:2012-11-11 08:36:30

标签: asp.net menubar

我在Site master中创建了一个常规菜单,其中包含链接和另一个扩展的MenuBar:

<div id="menu">

        <div class="MenuBar">
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            <asp:Menu ID="menuBar" runat="server" Orientation="Vertical" Width="100%">
                <DynamicHoverStyle CssClass="DynamicHover" />
                <DynamicMenuItemStyle CssClass="DynamicMenuItem" />
                <DynamicSelectedStyle CssClass="DynamicHover" />
                <StaticHoverStyle CssClass="staticHover" />
                <StaticMenuItemStyle CssClass="StaticMenuItem" ItemSpacing="1px" />
                <StaticSelectedStyle CssClass="staticHover" />
            </asp:Menu>
        </asp:ContentPlaceHolder>
    </div>


    <ul>
        <li class="current_page_item"><a href="#">ח</a></li>
        <li><a href="#">א</a></li>
        <li><a href="#">ה</a></li>
        <li><a href="#">ב</a></li>
        <li><a href="#">ב</a></li>
        <li class="last"><a href="#">חו</a></li>
    </ul>
</div>
  1. 为什么打开默认页面时没有显示MenuBar? 默认页面代码只是:

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
  2. 如何将菜单栏插入与主菜单中其他链接位于同一行?

1 个答案:

答案 0 :(得分:1)

MenuBar应该是asp:ContentPlaceHolder的外部

<div class="MenuBar">
<asp:Menu ID="menuBar" runat="server" Orientation="Vertical" Width="100%">
            <DynamicHoverStyle CssClass="DynamicHover" />
            <DynamicMenuItemStyle CssClass="DynamicMenuItem" />
            <DynamicSelectedStyle CssClass="DynamicHover" />
            <StaticHoverStyle CssClass="staticHover" />
            <StaticMenuItemStyle CssClass="StaticMenuItem" ItemSpacing="1px" />
            <StaticSelectedStyle CssClass="staticHover" />
        </asp:Menu>
</div>
<div id="menu">
 <ul>
    <li class="current_page_item"><a href="#">ח</a></li>
    <li><a href="#">א</a></li>
    <li><a href="#">ה</a></li>
    <li><a href="#">ב</a></li>
    <li><a href="#">ב</a></li>
    <li class="last"><a href="#">חו</a></li>
</ul>
</div>


    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>

为了在同一行显示MenuBar和ul,它们都必须是样式:

display: inline;