我是asp.net的新手,我正在设置必填字段验证器,它显示错误
错误是:
Unable to find control id 'txtFirstName' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'.
代码是:
<tr>
<td align="right" style="padding-right: 5px; width: 50%;">
<asp:Label ID="lblFirstName" runat="server" Text="FIRSTNAME :"></asp:Label>
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<asp:TextBox ID="txtFistName" runat="server" Width="70%"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtFirstName" ErrorMessage="You can't leave this empty."></asp:RequiredFieldValidator>
</td>
</tr>
可以帮助我解决这个问题......,
答案 0 :(得分:2)
您在TextBox
的ID中输入了错字号,您的标识为txtFistName
而非txtFirstName
,因此请进行更改。
更改
<asp:TextBox ID="txtFistName" runat="server" Width="70%"></asp:TextBox>
到的
<asp:TextBox ID="txtFirstName" runat="server" Width="70%"></asp:TextBox>