I am having a slight issue with the use of ValidationSummary(true) to display model level errors. If the ModelState does not contain model errors (i.e. M
Another variation of the fix with Bootstrap classes is:
public static class ValidationSummaryExtensions
{
public static MvcHtmlString CleanValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors, string message = null)
{
if(htmlHelper == null) throw new ArgumentNullException("htmlHelper");
MvcHtmlString validationSummary = null;
if (htmlHelper.ViewData.ModelState.ContainsKey(string.Empty))
{
var htmlAttributes = new { @class = "alert alert-danger" };
validationSummary = htmlHelper.ValidationSummary(excludePropertyErrors, message, htmlAttributes);
}
return validationSummary;
}
}