Using MVC 4/Razor
@HTML.ValidationSummary(True) generates:
- First Name is required.
- Last Name is required.
@HTML.ValidationSummary(True, "Please fix the following errors:") generates:
Please fix the following errors:
- First Name is required.
- Last Name is required.
I want to be able to default the "Please fix the following errors" so that putting
@HTML.ValidationSummary(True) would generate:
Please fix the following errors:
- First Name is required.
- Last Name is required.
Is there anyway to do that? I have this but have no idea where to put it:
@model ModelStateDictionary
@using System.Web.Mvc.Html
@using MvcSiteMapProvider.Web.Html.Models
<div class='@(Html.ViewData.ModelState.IsValid ? "validation-summary-valid" : "validation-summary-errors") data-valmsg-summary="true">
<span><strong>Please fix the following errors:</strong></span>
<ul>
@foreach (var modelError in Model.SelectMany(keyValuePair => keyValuePair.Value.Errors))
{
<li>@modelError.ErrorMessage</li>
}
</ul>
</div>