ValidationHelper.Add Method (String, IValidator[])
Registers a user input element for validation.
Namespace: System.Web.WebPages
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
Public Sub Add ( _
field As String, _
ParamArray validators As IValidator() _
)
'Usage
Dim instance As ValidationHelper
Dim field As String
Dim validators As IValidator()
instance.Add(field, validators)
public void Add(
string field,
params IValidator[] validators
)
public:
void Add(
String^ field,
... array<IValidator^>^ validators
)
member Add :
field:string *
validators:IValidator[] -> unit
public function Add(
field : String,
... validators : IValidator[]
)
Parameters
- field
Type: System.String
The name (value of the name attribute) of the user input element to validate.
- validators
Type: System.Web.WebPages.IValidator[]
A list of one or more types of validation to register.
Remarks
You can register the same user input element multiple times using different validation types. For example, you can register an element to be required and also the have a range or string length. However, you can only register a user input element once for a specific type of validation. For example, you can call this method in the following ways:
Validation.Add("description", Validator.Required(), Validator.StringLength(5));