ASP.net MVC Validation Summary

July 16, 2017

Show model validation errors in a bootstrap alert box

if (ViewData.ModelState.Keys.Any(k => ViewData.ModelState[k].Errors.Any()))
{
    <div class="alert alert-danger">
        @Html.ValidationSummary(false, "")
    </div>
}

Photo by Fancycrave.com from Pexels