Partager via


ValidationExtensions.ValidationMessage Method

Include Protected Members
Include Inherited Members

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.

Overload List

  Name Description
Public methodStatic member ValidationMessage(HtmlHelper, String) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public methodStatic member ValidationMessage(HtmlHelper, String, IDictionary<String, Object>) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public methodStatic member ValidationMessage(HtmlHelper, String, Object) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public methodStatic member ValidationMessage(HtmlHelper, String, String) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.
Public methodStatic 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 methodStatic member ValidationMessage(HtmlHelper, String, String, Object) Displays a validation message if an error exists for the specified field in the ModelStateDictionary object.

Top

Remarks

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.

See Also

Reference

ValidationExtensions Class

System.Web.Mvc.Html Namespace