Why is ValidationSummary(true) displaying an empty summary for property errors?

前端 未结 11 1128
傲寒
傲寒 2020-12-13 13:51

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

11条回答
  •  我在风中等你
    2020-12-13 14:17

    @if (ViewContext.ViewData.ModelState.Where(x => x.Key == "").Any())
    {
        @Html.ValidationSummary(true, null, new { @class = "ui-state-error" })
    }
    

    This checks if there are any model wide errors and only renders the summary when there are some.

提交回复
热议问题