验证(XHTML 1.0 Transitional):元素'html'不能嵌套在元素'div'中

时间:2012-05-07 22:25:18

标签: c# asp.net

我需要帮助如何修复代码中的错误。当我编译代码告诉我错误验证(XHTML 1.0 Transitional):元素'html'不能嵌套在元素'div'中。如果有人知道,请帮助我?

 <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageUsers.aspx.cs" Inherits="probazaadmin.ManageUsers" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form2" runat="server"></form>
    <div>Users Account Management</div>
    <p></p>
    <b>- The total registered users is: <asp:Literal runat="server" ID="lblTotalUsers" /><br />
    - The total online users at this moment: <asp:Literal runat="server" ID="lblOnlineUsers" /></b>
    <p></p>
    In order to display all users whose name begins with letter click on the link letter:
    <p></p>

    <asp:Repeater runat="server" ID="rptAlphabetBar"
    OnItemCommand="rptAlphabetBar_ItemCommand">
    <ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Container.DataItem %>'
    CommandArgument='<%# Container.DataItem %>' />&nbsp;&nbsp;
    </ItemTemplate>
    </asp:Repeater>
    <p></p>
    Use the below feature to search users by partial username or e-mail:
    <p></p>

    <asp:DropDownList runat="server" ID="ddlUserSearchTypes">
    <asp:ListItem Text="UserName" Selected="true" />
    <asp:ListItem Text="E-mail" />
    </asp:DropDownList>
    contains
    <asp:TextBox runat="server" ID="txtSearchText" />
    <asp:Button runat="server" ID="btnSearch" Text="Search"
    OnClick="btnSearch_Click" />
    </body></html>
    </asp:Content>

2 个答案:

答案 0 :(得分:3)

您的代码显示您:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master"....
  1. 使用母版页(HTML声明所在的位置)

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
  2. 使用内容占位符添加整个HTML文档 - 您不应该这样做。

    • 如上所述,母版页是HTML声明的地方
    • ASP.net内容部分仅供内容使用。

答案 1 :(得分:0)

您的代码应该是这样的 &lt;%@ Page Title =&#34;&#34;语言=&#34; C#&#34;的MasterPageFile =&#34;〜/的Site.Master&#34; AutoEventWireup =&#34;真&#34;代码隐藏=&#34; ManageUsers.aspx.cs&#34;继承=&#34; probazaadmin.ManageUsers&#34; %GT;                    用户帐户管理     

     - 注册用户总数为:
     - 此时在线用户总数:
    

    要显示名称以字母开头的所有用户,请单击链接字母:     

<asp:Repeater runat="server" ID="rptAlphabetBar"
OnItemCommand="rptAlphabetBar_ItemCommand">
<ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Container.DataItem %>'
CommandArgument='<%# Container.DataItem %>' />&nbsp;&nbsp;
</ItemTemplate>
</asp:Repeater>
<p></p>
Use the below feature to search users by partial username or e-mail:
<p></p>

<asp:DropDownList runat="server" ID="ddlUserSearchTypes">
<asp:ListItem Text="UserName" Selected="true" />
<asp:ListItem Text="E-mail" />
</asp:DropDownList>
contains
<asp:TextBox runat="server" ID="txtSearchText" />
<asp:Button runat="server" ID="btnSearch" Text="Search"
OnClick="btnSearch_Click" />
</asp:Content>