ValidationExtensions Class

 

Provides support for validating the input from an HTML form.

Namespace:   System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

System.Object
  System.Web.Mvc.Html.ValidationExtensions

<ExtensionAttribute>
Public NotInheritable Class ValidationExtensions

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticResourceClassKey

Gets or sets the name of the resource file (class key) that contains localized string values.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticValidate(HtmlHelper, String)

Retrieves the validation metadata for the specified model and applies each rule to the data field.

System_CAPS_pubmethodSystem_CAPS_staticValidateFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)))

Retrieves the validation metadata for the specified model and applies each rule to the data field.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String)

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, IDictionary(Of String, Object))

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, IDictionary(Of String, Object), String)

Displays a validation message if an error exists for the specified entry in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, Object)

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, Object, String)

Displays a validation message if an error exists for the specified entry in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String)

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String, IDictionary(Of String, Object))

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String, IDictionary(Of String, Object), String)

Displays a validation message if an error exists for the specified entry in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String, Object)

Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String, Object, String)

Displays a validation message if an error exists for the specified entry in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessage(HtmlHelper, String, String, String)

Displays a validation message if an error exists for the specified entry in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object), String)

Returns the HTML markup for a validation-error message for the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object, String)

Returns the HTML markup for a validation-error message for the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, String)

Returns the HTML markup for a validation-error message for the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper)

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean)

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String)

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String, IDictionary(Of String, Object))

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String, IDictionary(Of String, Object), String)

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String, Object)

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String, Object, String)

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, Boolean, String, String)

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String)

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String, IDictionary(Of String, Object))

Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String, IDictionary(Of String, Object), String)

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String, Object)

Returns an unordered list (ul element) of validation messages in the ModelStateDictionary object.

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String, Object, String)

System_CAPS_pubmethodSystem_CAPS_staticValidationSummary(HtmlHelper, String, String)

The ValidationExtensions class contains methods that extend the HtmlHelper class. The ValidationMessage method renders a validation message if the specified field contains invalid input. The ValidationSummary method displays a list of all validation messages on the page. These methods require the view to be strongly typed.

If the DefaultModelBinder instance cannot bind a form-field value to the model, the binder adds an error to the ModelState object. When the view is rendered, the validation messages and validation summary are displayed based on the Errors property of the ModelState object.

You can control the appearance of the validation messages and validation summary by modifying the following cascading style sheet (CSS) classes in the Site.css file:

  • input-validation-error. This rule is applied to the input element that is rendered by the TextBox helper method.

  • field-validation-error. This rule is applied to the span element that is rendered by the ValidationMessage method.

  • validation-summary-error. This rule is applies to the ul element that is rendered by the ValidationMessage method.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: