2016-03-15 100 views
-2

在aspx文件的Runat錯誤:的Runat錯誤4

這是我的代碼:

<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>

誤差:將與RUNAT =服務器form標籤的控制。 和我在所有的asp代碼放置runat服務器,但它仍然是相同的,當即時調試它一直說我:將控件放在窗體標籤與runat =服務器。

回答

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>