ValidationExtensions.ValidationMessage Method

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

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Static member ValidationMessage(HtmlHelper, String) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public method Static member ValidationMessage(HtmlHelper, String, IDictionary<String, Object>) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public method Static member ValidationMessage(HtmlHelper, String, Object) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public method Static member ValidationMessage(HtmlHelper, String, String) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public method Static member ValidationMessage(HtmlHelper, String, String, IDictionary<String, Object>) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public method Static member ValidationMessage(HtmlHelper, String, String, Object) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Top

The ValidationMessage method renders a validation message if the specified field contains invalid input.

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.

Show: