I want to make custom @Html.ValidationMessageFor
.
I have this code, but it uses @Html.ValidationMessageFor
, and now brings the HTML formatted, and only want the return of the errors.
How to do this?
My code:
public static MvcHtmlString MyValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression)
{
return MvcHtmlString.Create(helper.ValidationMessageFor(expression).ToString());
}