BHARATH
BHARATH

Reputation: 85

required field validator

i am new to asp.net and i am setting required field validator and it is showing me an error

error is:

Unable to find control id 'txtFirstName' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'. 

code is:

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

can any help me on this flow....,

Upvotes: 1

Views: 491

Answers (1)

Adil
Adil

Reputation: 148180

You have typo in the id of TextBox, you have id txtFistName not txtFirstName so change it.

Change

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

To

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

Upvotes: 2

Related Questions