1

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

任何人都可以在这个流程上帮助我......,

4

1 回答 1

2

你的 id 有错字TextBox,你有 idtxtFistName没有txtFirstName那么改变它。

改变

<asp:TextBox ID="txtFistName" runat="server" Width="70%"></asp:TextBox>

<asp:TextBox ID="txtFirstName" runat="server" Width="70%"></asp:TextBox>
于 2013-04-02T07:19:09.610 回答