Html.ValidationMessage文本颜色 [英] Html.ValidationMessageFor Text Color
问题描述
可能是一个简单的问题,但我似乎找不到答案。
使用MVC 2我有一系列的Html.ValidationFor控件。我想为文本分配一个CSS类,而且似乎不能这么做。
<%= Html.TextBoxFor => Model.Chest,new {@class =textBoxMeasure})%>
<%= Html.ValidationMessageFor(Model => Model.Chest)%>
如果我尝试与textbox相同的方法,我得到错误,因为它需要一个字符串,当我把一个
有一个变量,它将htmlAttributes作为第三个参数(第二个是应该显示的消息,或者您可以使用null作为默认验证消息)
Html.ValidationMessageFor(
Model => Model.Chest,
请输入值,
new {@class =redText})
有关详细信息,请参阅 http://msdn.microsoft.com/en-us/library/ee721293%28v=vs.98%29.aspx
Probably a simple question, but i cant seem to find the answer.
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) %>
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!
thanks
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" })
For more info see http://msdn.microsoft.com/en-us/library/ee721293%28v=vs.98%29.aspx
这篇关于Html.ValidationMessage文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!