I'm trying to add a css class to a textbox. This is what I have in my view:
<%: Html.EditorFor(m => m.StartDate) %>
I tried following the instructions at this link by making my code:
<%: Html.EditorFor(m => m.StartDate, new { @class: "datepicker" }) %>
But I get a compiler error saying:
Syntax error, ',' expected
What am I doing wrong here?
With MVC3, I kept banging my head because I couldn't get this to work. I didn't want to create a whole EditorTemplate for just adding one class.
Well, instead of using EditorFor, use TextBoxFor, with of course the equals sign like so:
@Html.TextBoxFor(m=> m.ZipCode, new { @class = "zip" })
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