I want to validate a text area using required field validator but when i select control to validate from properties then the textarea id of this text area is not getting displayed.
What's wrong with it ?
Can anybody know this?

Dani AI

Generated

The ControlToValidate list in the validator properties only shows valid server-side input controls. As noted, a plain HTML <textarea> or a control inside a template often will not appear in that dropdown. is right that the validator must point to the control, but that control must also be a run-time ASP.NET input control that exposes a value for validation (BaseValidator.ControlToValidate).

Common fixes and examples:

  • Use an ASP.NET TextBox set to multi-line (recommended):
<asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" />
<asp:RequiredFieldValidator ID="rfvComments" runat="server"
    ControlToValidate="txtComments" ErrorMessage="Comments required" />
  • Or make an HTML textarea a server control:
<textarea id="txtComments" runat="server"></textarea>
<asp:RequiredFieldValidator ID="rfvComments" runat="server"
    ControlToValidate="txtComments" ErrorMessage="Comments required" />

Additional troubleshooting notes:

  • A control must have runat="server" and an ID. Controls inside templates (GridView/Repeater/TemplateField/UserControl) will not appear in the designer dropdown — place the validator inside the same template or set ControlToValidate in code after FindControl.
  • The target control must expose a validation property (standard ASP.NET input controls do; custom controls need the ValidationPropertyAttribute).
  • If the designer still hides the control, manually type the server ID into ControlToValidate or save/close/reopen the page to refresh the designer.

Quick checklist: control has runat="server", an ID, is not only a static HTML element, validator and control are in the same naming container, and the control exposes a value property for validation. For reference on standard input controls see the TextBox docs (TextBox class).

just add control to validate property to the control u want to validate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.