Export (0) Print
Expand All

ValidationExtensions.ValidationSummary Method (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.

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

public static MvcHtmlString ValidationSummary(
	this HtmlHelper htmlHelper,
	bool excludePropertyErrors,
	string message,
	Object htmlAttributes
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper
The HTML helper instance that this method extends.
excludePropertyErrors
Type: System.Boolean
true to have the summary display model-level errors only, or false to have the summary display all errors.
message
Type: System.String
The message to display with the validation summary.
htmlAttributes
Type: System.Object
An object that contains the HTML attributes for the element.

Return Value

Type: System.Web.Mvc.MvcHtmlString
A string that contains an unordered list (ul element) of validation messages.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HtmlHelper. When you use instance method syntax to call this method, omit the first parameter. For more information, see b8020aae-374d-46a9-bcb7-8cc2390b93b6 or 175ce3ff-9bbf-4e64-8421-faeb81a0bb51.

The ValidationSummary method displays a list of all validation messages on the page.

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:
© 2014 Microsoft