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 class
attribute for your CSS rule to match:
@Html.TextBoxFor(m => m.Notes[i].Notes, new { @class = "myStyle" });
Note that the @
in @class
has no special meaning in ASP.NET MVC. It's simply there to turn class
, a keyword in C#, into an identifier, so you can pass it in as a property and it'll compile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With