我将引导程序与 ASP.NET Core 一起使用,并指示表单字段验证错误,当给定字段出现错误时,我想将has-errors
类添加到form-group
div。视图如下所示:
<div class="form-group">
<label asp-for="Fragment.Content" class="col-lg-2 control-label "></label>
<div class="col-lg-10">
<textarea asp-for="Fragment.Content" class="form-control content-editor"></textarea>
<span class="help-block">A longer block of help text that breaks onto a new line and may extend beyond one line.</span>
<span asp-validation-for="Fragment.Content"></span>
</div>
</div>
我想做类似的事情:
<div class="form-group" asp-add-class-if-error="has-errors" for-field="Fragment.Content"/>
我知道我可以编写自己的标签助手,但是我很好奇是否有内置的解决方案。