Open
Description
Describe the bug
If use @Html.EditorFor
with the expression for a property, client-side validation will display error message with wrong css style.
The class
attribute has no value
To Reproduce
@for (var i = 0; i < Model.TestChildModels.Count; i++)
{
@Html.EditorFor(model => model.TestChildModels[i])
}
EditorTemplate/TestChildModel.cshtml
@model TestChildModel
<div class="row">
<div class="col-4">
<input asp-for="Id" />
<span asp-validation-for="Id" class="text-danger"></span>
</div>
<div class="col-4">
<input asp-for="Name" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="col-4">
<input asp-for="Count" />
<span asp-validation-for="Count" class="text-danger"></span>
</div>
</div>
The workaround I am using now
add following code snippet in site.css
span.field-validation-error span {
color: red;
}
Further technical details
- ASP.NET Core version 5.0