Validator.StringLength Method

Defines a validation test that tests the length of a string.

Namespace:  System.Web.WebPages
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)

Syntax

'Declaration
Public Shared Function StringLength ( _
    maxLength As Integer, _
    minLength As Integer, _
    errorMessage As String _
) As IValidator
'Usage
Dim maxLength As Integer 
Dim minLength As Integer 
Dim errorMessage As String 
Dim returnValue As IValidator 

returnValue = Validator.StringLength(maxLength, _
    minLength, errorMessage)
public static IValidator StringLength(
    int maxLength,
    int minLength,
    string errorMessage
)
public:
static IValidator^ StringLength(
    int maxLength, 
    int minLength, 
    String^ errorMessage
)
static member StringLength : 
        maxLength:int * 
        minLength:int * 
        errorMessage:string -> IValidator
public static function StringLength(
    maxLength : int, 
    minLength : int, 
    errorMessage : String
) : IValidator

Parameters

  • maxLength
    Type: System.Int32
    The maximum length of the string.
  • minLength
    Type: System.Int32
    The minimum length of the string. The default is 0.
  • errorMessage
    Type: System.String
    The error message to display if validation fails.

Return Value

Type: System.Web.WebPages.IValidator
The validation test.

See Also

Reference

Validator Class

System.Web.WebPages Namespace