In ASP.NET MVC I could define a textBox editor like this and give it a style.
@Html.TextBoxFor(m => m.Notes[i].Notes, new { style = "width: 500px;" });
How can I move the style to the Site.css file and just refer to it from the code above?
.myStyle {
width: 500px;
}
I tried this which compiles but doesn’t seem to work:
@Html.TextBoxFor(m => m.Notes[i].Notes, "myStyle");
You want to give it a
classattribute for your CSS rule to match:Note that the
@in@classhas no special meaning in ASP.NET MVC. It’s simply there to turnclass, a keyword in C#, into an identifier, so you can pass it in as a property and it’ll compile.