aspx文件4

时间:2016-03-15 13:56:44

标签: c# asp.net server runat

aspx文件中的Runat错误:

这是我的代码:



<table>
    <tr><td>First Name:</td><td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td></tr>
    <tr><td>Last Name:</td><td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td></tr>
    <tr><td>Username:</td><td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td></tr>
    <tr><td>Passowrd:</td><td><asp:TextBox ID="TextBox4" TextMode="Password" runat="server"></asp:TextBox></td></tr>
    <tr><td>Confirm Password:</td><td><asp:TextBox ID="TextBox5" TextMode="Password" runat="server"></asp:TextBox></td></tr>
    <tr><td>Gender:</td>
        <td>
            <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                <asp:ListItem>Male</asp:ListItem>
                <asp:ListItem>FeMale</asp:ListItem>
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr><td>Email:</td><td><asp:TextBox ID="TextBox6" TextMode="Email" runat="server"></asp:TextBox></td></tr>
    <tr><td><asp:Button ID="Button1" Text="Register" runat="server"/></td></tr>
</table>
&#13;
&#13;
&#13;

错误:将控件放在带有runat = server的表单标记中。 我在所有的asp代码中放置了runat服务器,但它仍然是相同的,当我调试时,它一直在说我:将控件放在带有runat = server的表单标签中。

1 个答案:

答案 0 :(得分:0)

您必须将控件放在表单元素中:

<form ID="form1" runat="server">
    <table>
        <tr><td>First Name:</td><td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td></tr>
        <tr><td>Last Name:</td><td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td></tr>
        <tr><td>Username:</td><td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td></tr>
        <tr><td>Passowrd:</td><td><asp:TextBox ID="TextBox4" TextMode="Password" runat="server"></asp:TextBox></td></tr>
        <tr><td>Confirm Password:</td><td><asp:TextBox ID="TextBox5" TextMode="Password" runat="server"></asp:TextBox></td></tr>
        <tr><td>Gender:</td>
            <td>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                    <asp:ListItem>Male</asp:ListItem>
                    <asp:ListItem>FeMale</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr><td>Email:</td><td><asp:TextBox ID="TextBox6" TextMode="Email" runat="server"></asp:TextBox></td></tr>
        <tr><td><asp:Button ID="Button1" Text="Register" runat="server"/></td></tr>
    </table>
</form>