Skip to content

Instantly share code, notes, and snippets.

@jonathanconway
Created November 22, 2010 09:23
Show Gist options
  • Save jonathanconway/709722 to your computer and use it in GitHub Desktop.
Save jonathanconway/709722 to your computer and use it in GitHub Desktop.
ASP.NET MVC - Output full-HTML validation errors
public static class ValidationExtensions
{
public static MvcHtmlString ValidationMessageHtmlFor<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
bool htmlEncode)
{
return new MvcHtmlString(
HttpUtility.HtmlDecode(
htmlHelper.ValidationMessageFor<TModel, TProperty>(
expression,
null,
((IDictionary<string, object>)new RouteValueDictionary()))
.ToHtmlString()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment