Render HTML in a Validation Message in ASP.NET MVC
Often times you may want to render a custom validation message that contains HTML markup. If you simply add the line:
@Html.ValidationSummary()
This will encode the markup so that less than signs and greater than signs are rendered < and >, respectively. This, of course, is not what you want.
To render your HTML markup, its a little dirty, but it does work.
Simply add the following to your view:
@Html.Raw(HttpUtility.HtmlDecode(Html.ValidationMessageFor(m => m.Email).ToHtmlString()))
Where "Email" is a property of your model.