40

I have tried:

@Html.TextBoxFor(m => m.UserName, new {@class='textbox'})

which isn't working.

1 Answer 1

67
@Html.TextBoxFor(m => m.UserName, new {@class="textbox"})

A c# string literal does not take single quotes.

'textbox' -> "textbox"

2
  • You'r so right.. I blame it on the later hour... Shouldn't be coding in the middle of the night. Even the exception messages was telling me this (mayby in a more cryptic way) Oct 24, 2010 at 7:35
  • 1
    For multiple classes e.g... @Html.TextBoxFor(m => m.UserName, new {@class="textbox, anotherClass"})
    – CYoung
    Sep 30, 2016 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.