如何更改字体和使用Html.TextAreaFor时的颜色?

时间:2010-05-26 09:28:08

标签: asp.net html asp.net-mvc

我正在使用以下代码显示一些文字,它不会改变字体颜色,任何人都知道为什么?

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, new { cols = "40%", Style = new Style { ForeColor = Color.Red } })%>

1 个答案:

答案 0 :(得分:11)

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, 
    new { cols = "40%", style = "color:red;" })%>

或应用css样式:

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, 
    new { cols = "40%", @class = "foo" })%>

看起来像这样:

.foo {
    color: red;
}