2

我有一个奇怪的问题。我在我的 .master 页面中添加了一个 asp:menu 控件。还添加了一些项目和子项目。但是,我不知道为什么,我可以在设计时看到控件,但在运行时找不到它。可见属性设置为 true。即使在查看源代码时也缺少该控件。

这是代码

 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="CMSFirst.master.cs" Inherits="CMSFirst.CMSFirst" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
   </asp:ContentPlaceHolder>
</head>
  <body>
    <form id="form1" runat="server">

 <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
                <asp:Menu ID="Menu2" runat="server">
                    <Items>
                        <asp:MenuItem Text="Članki" Value="Nov"></asp:MenuItem>
                        <asp:MenuItem Text="Nastavitve" Value="Nastavitve">
                            <asp:MenuItem Text="Pisava" Value="Pisava"></asp:MenuItem>
                            <asp:MenuItem Text="Oblika" Value="Oblika"></asp:MenuItem>
                        </asp:MenuItem>
                        <asp:MenuItem Text="Pomoč" Value="Pomoč"></asp:MenuItem>
                    </Items>
                </asp:Menu>
            </asp:ContentPlaceHolder>


<table border="0" cellpadding="2" cellspacing="0">
    <tr>
        <td>
            <img src="Images/logo.jpg" alt="CMSFirst" />
        </td>
    </tr>
    <tr>
        <td>
              <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                <asp:Menu ID="Menu1" runat="server">
                    <Items>
                        <asp:MenuItem Text="Članki" Value="Nov"></asp:MenuItem>
                        <asp:MenuItem Text="Nastavitve" Value="Nastavitve">
                            <asp:MenuItem Text="Pisava" Value="Pisava"></asp:MenuItem>
                            <asp:MenuItem Text="Oblika" Value="Oblika"></asp:MenuItem>
                        </asp:MenuItem>
                        <asp:MenuItem Text="Pomoč" Value="Pomoč"></asp:MenuItem>
                    </Items>
                </asp:Menu>
             </asp:ContentPlaceHolder>
        </td>
    </tr>
    <tr>
        <td>
            <p>
                <strong>Website design by Me</strong></p>
            <asp:LoginStatus ID="LoginStatus1" runat="server" />
        </td>
    </tr>
</table>
</form>

我googlesd了很多,但找不到原因。

谢谢

4

1 回答 1

0

我的带有菜单的示例母版页:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form runat="server">
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    My ASP.NET Application
                </h1>
            </div>
            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
                    IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />
                    </Items>
                </asp:Menu>
            </div>
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
    </div>
    </form>
</body>
</html>

我的默认页面

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
</asp:Content>

我的关于页面示例

<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="About.aspx.cs" Inherits="About" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        About
    </h2>
    <p>
        Put content here.
    </p>
</asp:Content>
于 2013-01-14T21:08:49.197 回答