I just want to make such an Assistant:
public static MvcHtmlString HasError<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
{
StringBuilder sb = new StringBuilder();
if (!ModelState.IsValidField(ExpressionHelper.GetExpressionText(expression)))
sb.Append("has-error");
return MvcHtmlString.Create(sb.ToString());
}
So the question is how to access the actual ModelState here?
source
share