79263647

Date: 2024-12-09 01:35:28
Score: 1
Natty:
Report link

Solved.

Simple solution, you only need to implement this validation into the tagHelper:

var modelState = ViewContext?.ViewData.ModelState;
    if (modelState != null
        && For != null
        && modelState.TryGetValue(For.Name, out ModelStateEntry? entry)
        && entry.Errors.Count > 0)
    {
        validation.InnerHtml.Append(unencoded: entry.Errors[0].ErrorMessage);
    }
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Joan Alexander