Skip to main content

Validation Summary

  • 2 minutes to read

ValidationSummary is an extension that allows you to summarize validation errors from multiple data editors.

Implementation Details

ValidationSummary is realized by the ValidationSummaryExtension class. Its instance can be accessed via the ExtensionsFactory.ValidationSummary helper method, which is used to add a ValidationSummary extension to a view. This method’s parameter provides access to the ValidationSummary‘s settings implemented by the ValidationSummarySettings class, allowing you to fully customize the extension.

The ValidationSummary‘s client counterpart is represented by the ASPxClientValidationSummary object.

Declaration

ValidationSummary can be added to a view in the following manner.

@using (@Html.BeginForm()) { 
    @Html.DevExpress().ValidationSummary().GetHtml()
    <table>
        <tr>
            <td>@Html.DevExpress().LabelFor(model => model.FirstName).GetHtml()</td>
            <td>@Html.DevExpress().TextBox(
                settings => {
                    settings.Name = "FirstName";
                    settings.ShowModelErrors = true;
                    settings.Properties.ValidationSettings.Display = Display.None;
                }).Bind(Model.FirstName).GetHtml()</td>
        </tr>
    ...
    </table>
...
}

The code result is demonstrated in the image below.

MVC_Validation_DXValidationSummary

Main Features

The ValidationSummary extension allows you to summarize validation errors from multiple editors and then display these errors in a single block.

ASPxValidationSummary_concepts_overview.png

Note

The ValidationSummary does not display errors added through the ModelState.AddModelError method when it gets a key that does not match the editor ID.

ValidationSummary provides the following features:

  • Three Render Modes

    Use the ValidationSummarySettings.RenderMode property to specify how the ValidationSummary‘s panel displays validation error texts:

    Appearance Affected Properties
    ASPxValidationSummary_table RenderMode=Table
    ASPxValidationSummary_bulletedlist RenderMode=BulletedList
    ASPxValidationSummary_orderedlist RenderMode=OrderedList
  • Show Error Texts as Links

    Set the ValidationSummarySettings.ShowErrorAsLink property to true to show validation error texts as links. In this mode, click a link to move focus to a corresponding invalid editor.

    ASPxValidationSummary_concepts_overview_links

  • Full-Featured Client-Side API

    The ASPxClientValidationSummary object is a client-side equivalent of the ValidationSummary extension and can be used to access its client-side API.