40

I have tried:

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

which isn't working.

ahsteele
  • 26,243
  • 28
  • 134
  • 248
Magnus Gladh
  • 1,817
  • 4
  • 20
  • 31

1 Answers1

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

A c# string literal does not take single quotes.

'textbox' -> "textbox"

Flexo
  • 87,323
  • 22
  • 191
  • 272
takepara
  • 10,413
  • 3
  • 34
  • 31
  • 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) – Magnus Gladh Oct 24 '10 at 07:35
  • 1
    For multiple classes e.g... @Html.TextBoxFor(m => m.UserName, new {@class="textbox, anotherClass"}) – CYoung Sep 30 '16 at 01:20