Add Validator (ASP.NET)

Adds a selected Validator to the active input control (the control containing the caret).


Add Validator makes it much easier to create validators associated with a specific input control. It automatically constructs proper validator syntax, binds the created validator to the source control and navigates you through attributes you are likely to specify.


Available from the context menus or via shortcuts:

  • when the caret is within or before a tag that represents a server input control.


  • Refactor! context menu allows you to choose among five available Validator types: CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator and RequiredFieldValidator. Please refer to the corresponding class descriptions for details on features provided by these validator types.
  • Add Validator creates text fields so you can easily navigate between validator attributes and change their values.


<asp:TextBox ID="TextBox1" runat="server">my text</asp:TextBox>


<asp:TextBox ID="TextBox1" runat="server">my text</asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" ControlToValidate="TextBox1" 
ControlToCompare="TextBox1" ErrorMessage="CompareValidator" runat="server" />