aspnetmvc-12359-components-data-editors-extensions-validationsummary.md
ValidationSummary is an extension that allows you to summarize validation errors from multiple data editors.
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.
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.
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