Share via


ValidationHelper.ClassFor Method

Renders an attribute that references the CSS style definition to use when validation messages for the user input element are rendered.

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

Syntax

'Declaration
Public Function ClassFor ( _
    field As String _
) As HtmlString
'Usage
Dim instance As ValidationHelper 
Dim field As String 
Dim returnValue As HtmlString 

returnValue = instance.ClassFor(field)
public HtmlString ClassFor(
    string field
)
public:
HtmlString^ ClassFor(
    String^ field
)
member ClassFor : 
        field:string -> HtmlString
public function ClassFor(
    field : String
) : HtmlString

Parameters

  • field
    Type: System.String
    The name (value of the name attribute) of the user input element to validate.

Return Value

Type: System.Web.HtmlString
The attribute.

Remarks

This method renders attributes that defines the look of the element and of any validation error messages. For information about defining CSS styles to specify the appearance of error display, see the ValidationHelper class overview.

You call this method inside the markup of an individual user input element when you are using client-side validation. (You must also have previously included the required JavaScript libraries.) When the method is invoked, it renders the appropriate attributes so that the client-side validation routines can dynamically render the CSS class elements that specify how error display is rendered.

See Also

Reference

ValidationHelper Class

System.Web.WebPages Namespace