标记:
<div class="form-bottom">
<form role="form" action="#" method="post" class="login-form">
<div class="form-group">
<asp:Label ID="Label1" runat="server" for="form-username" Text="Username" CssClass="sr-only"></asp:Label>
<%--<label class="sr-only" for="form-username">Username</label>--%>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<%--<input type="text" name="form-username" placeholder="Username..." class="form-username form-control" id="form-username">--%>
</div>
<div class="form-group">
<label class="sr-only" for="form-password">Password</label>
<%--<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>--%>
<input type="password" name="form-password" placeholder="Password..." class="form-password form-control" id="form-password">
</div>
<button type="submit" class="btn">Sign in!</button>
</form>
</div>
我收到此错误:
类型为'TextBox'的控件'log_TextBox1'必须放置在带有runat = server的表单标记中。
帮我解决问题
答案 0 :(得分:0)
您应该从代码中删除一个表单标签,因为asp.net页只能包含一个表单标签
<div class="form-bottom">
<form role="form" action="#" method="post" class="login-form">
<div class="form-group">
<asp:Label ID="Label1" runat="server" for="form-username" Text="Username" CssClass="sr-only"></asp:Label>
<label class="sr-only" for="form-username">Username</label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input type="text" name="form-username" placeholder="Username..." class="form-username form-control" id="form-username">
<br/>
<label class="sr-only" for="form-password">Password</label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input type="password" name="form-password" placeholder="Password..." class="form-password form-control" id="form-password">
<br/>
<button type="submit" class="btn">Sign in!</button>
</form>
</div>