I have a view (skipping redundant code for simplicity):
@model CompetencyModel
@using (Html.BeginForm())
{
@Html.ValidationSummary()
@Html.EditorFor(model => model.Results)
}
When I submit, if validation fails inside EditorFor
, ValidationSummary shows the list of all validation messages for each item coming from EditorFor
.
This screenshot is a view, where EditorFor
is a single line with radio buttons:
But I need a single error message just saying that something failed. I tried:
@Html.ValidationSummary(true)
@Html.EditorFor(model => model.Results)
But it doesn't show anything. I tried
@Html.ValidationSummary(true)
@Html.EditorFor(model => model.Results)
@Html.ValidationMessageFor(model => model.Results, "ERROR !!!")
But it doesn't show anything.
What am I doing wrong? Thank you.
Solution This will do the trick.
<style>.validation-summary-errors ul { display: none; }</style>
@Html.ValidationSummary("Can't save, you must answer all questions !!")