views:

599

answers:

2

I'm using following code to display some text and it won't change the font color, anyone know why?

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, new { cols = "40%", Style = new Style { ForeColor = Color.Red } })%>
+3  A: 
<%= Html.TextAreaFor(m => m.Component.ApplicationDescription, 
    new { cols = "40%", style = "color:red;" })%>

or apply a css style:

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

which could look like this:

.foo {
    color: red;
}
Darin Dimitrov
that mean ` Style = new` was the mistake...!!!
jjj
or using `{}` in `Style = new Style { ForeColor = Color.Red } `??!
jjj
@jjj, using `Style = new Style { ForeColor = Color.Red }` will generate the following HTML: `Style="System.Web.UI.WebControls.Style"` which is far from what browsers consider as valid HTML.
Darin Dimitrov
@Darin ...thanks
jjj
A: 

If you are using MVC2 here is the solution I found.

rtwPhoenix