class="field-validation-error help-inline" means that the span has both the field-validation-error AND the help-inline classes. You should just add the styling you want to the help-inline class. I don't think there's a way to not have the default generated.
"If I can see further than anyone else, it is only because I am standing on the shoulders of giants."blog: www.heartysoft.com twitter: @ashic
ankur.nigam
Member
536 Points
141 Posts
How to apply custom CSS Class in @Html.ValidationMessageFor
Jan 01, 2012 12:43 PM|LINK
Hello,
I am working in MVC 3 + Razor engine.
For rendering error message, I am using the following commnand.
@Html.ValidationMessageFor(model => model.ProfileName, String.Empty , new { @class = "help-inline", @style="color:red" })It generates the following HTML Markup.
But, I would prefer CSS class to be only "help-inline" instead of "field-validation-error help-inline"
How can I do this?
PS: "field-validation-error" is automatically added by the engine.
Ankur
My Blogs:
Twitter | DevAstrum
HeartattacK
All-Star
55262 Points
5917 Posts
Moderator
MVP
Re: How to apply custom CSS Class in @Html.ValidationMessageFor
Jan 01, 2012 01:08 PM|LINK
blog: www.heartysoft.com
twitter: @ashic
ABircan
Member
2 Points
1 Post
Re: How to apply custom CSS Class in @Html.ValidationMessageFor
Feb 21, 2013 12:41 PM|LINK
practical solution to a different
@Html.ValidationMessageFor(model => model.AccountName, String.Empty, new { @style="color:red;!important"})