1

Is there a way to display something more then plain text using MVC Validation helper methods? I tried to display somthing like this:

Controller:

string msg = "Error <span style='color:blue;'> bla bla bla</span>";
ModelState.AddModelError("model", msg);

View:

<span ...>@Html.ValidationSummary()</span>

But I get plain text:

"Error <span style='color:blue;'> bla bla bla</span>"

instead of "Error " and blue "bla bla bla":

I tried to pass as msg:

var msg2= MvcHtmlString.Create(msg);
var msg3= new HtmlString(msg);
var msg4= msg3.ToHtmlString();

But it helps nothing.

Interesting, when I use FireBug, and edit UL / LI tag generated by @Html.ValidationSummary() it can display such styles.

Of course - I can change style of validation css: - but it change whole text generated by helper method - which is not what I want.

Any suggestion? Thanks in advance

user3057544
  • 807
  • 9
  • 22
  • This question has already beeen answered http://stackoverflow.com/questions/6899609/validationsummary-and-validationmessagefor-with-custom-css-shown-when-no-errors – Armen Abrami Dec 02 '13 at 13:41
  • Armen Abrami, it is not the answer to my question - the link you provide is about styling whole text of validated message. My question is how to "say" to browser to parse text with tags - not to display it as plain text. – user3057544 Dec 02 '13 at 14:16

0 Answers0