Html.ValidationMessageFor文本颜色 [英] Html.ValidationMessageFor Text Color
问题描述
也许一个简单的问题,但我不能似乎找到了答案。
Probably a simple question, but i cant seem to find the answer.
使用MVC 2我有一系列Html.ValidationFor控制。我要分配一个CSS类的文字,并不能似乎做到这一点。
using MVC 2 i have a series of Html.ValidationFor controls. I want to assign a CSS class to the text and cant seem to do it.
<%= Html.TextBoxFor(Model => Model.Chest, new { @class = "textBoxMeasure" })%>
<%= Html.ValidationMessageFor(Model => Model.Chest) %>
如果我尝试同样的方法textboxfor我得到的错误,因为它需要一个字符串,当我在它把一个字符串仍不会工作!
if i try the same method as textboxfor i get errors because it requires a string, when i put a string in it still wont work!
感谢
推荐答案
有一个变种,需要htmlAttributes作为第三个参数(第二个是要显示的消息,也可以使用空默认验证消息)
There's a variant that takes htmlAttributes as the third argument (the second is the message that should be displayed, or you can use null for the default validation message)
Html.ValidationMessageFor(
Model => Model.Chest,
"Please enter a value",
new { @class = "redText" })
有关详细信息请参见的http:// msdn.microsoft.com/en-us/library/ee721293%28v=vs.98%29.aspx
这篇关于Html.ValidationMessageFor文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!