You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I create a HTML tag to display a "form-group" (Bootstrap4) including the validation message? The tag helper is <span asp-validation-for="Property" class="text-danger"></span>.
What I've got is
publicstaticHtmlTagFormBlock<T>(thisIHtmlHelper<T>helper,Expression<Func<T,object>>expression,Action<HtmlTag>labelModifier=null,Action<HtmlTag>inputModifier=null)whereT:class{labelModifier=labelModifier??(_ =>{});inputModifier=inputModifier??(_ =>{});vardivTag=newHtmlTag("div");divTag.AddClass("form-group");varlabelTag=helper.Label(expression);labelModifier(labelTag);varinputTag=helper.Input(expression);inputModifier(inputTag);varhtmlAttributes=newDictionary<string,string>{["class"]="text-danger"};// TODO Create HtmlTag so it can be modified like input and label divTag.Append(labelTag);divTag.Append(inputTag);returndivTag;}
Thanks
The text was updated successfully, but these errors were encountered:
You'll need to poke into the model state to pluck out the validation messages. You can find out how this is done by going through the ASP.NET Core source code and finding that tag helper that's built in.
Hi,
How do I create a HTML tag to display a "form-group" (Bootstrap4) including the validation message? The tag helper is
<span asp-validation-for="Property" class="text-danger"></span>
.What I've got is
Thanks
The text was updated successfully, but these errors were encountered: