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)

public HtmlString ClassFor(
	string 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.

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.