Back to Devexpress

Validation Summary

aspnetmvc-12359-components-data-editors-extensions-validationsummary.md

latest2.4 KB
Original Source

Validation Summary

  • Dec 17, 2020
  • 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.

aspx
@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.

Main Features

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

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

  • Show Error Texts as Links

  • Full-Featured Client-Side API