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

2
  • This question has already beeen answered stackoverflow.com/questions/6899609/… Commented Dec 2, 2013 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. Commented Dec 2, 2013 at 14:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.