Skip to content

Instantly share code, notes, and snippets.

@rippo
Last active August 29, 2015 14:07
Show Gist options
  • Save rippo/84cf57dc873ae213c29c to your computer and use it in GitHub Desktop.
Save rippo/84cf57dc873ae213c29c to your computer and use it in GitHub Desktop.
Bootstrap validation errors
public static MvcHtmlString BootStrapValidationSummary(this HtmlHelper helper)
{
if (helper.ViewData.ModelState.Keys.Any(k => helper.ViewData.ModelState[k].Errors.Any()))
{
return MvcHtmlString.Create("<div class='alert alert-danger'>"
+ "<button class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>"
+ helper.ValidationSummary(false, "Please check the following:")
+ "</div>");
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment