次の方法で共有


ValidationExtensions.ValidationSummary Method (HtmlHelper, String, Object)

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

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

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function ValidationSummary ( _
    htmlHelper As HtmlHelper, _
    message As String, _
    htmlAttributes As Object _
) As MvcHtmlString
public static MvcHtmlString ValidationSummary(
    this HtmlHelper htmlHelper,
    string message,
    Object htmlAttributes
)
[ExtensionAttribute]
public:
static MvcHtmlString^ ValidationSummary(
    HtmlHelper^ htmlHelper, 
    String^ message, 
    Object^ htmlAttributes
)

Parameters

  • message
    Type: System.String
    The message to display if the specified field contains an error.
  • 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 Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

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.

See Also

Reference

ValidationExtensions Class

ValidationSummary Overload

System.Web.Mvc.Html Namespace