Magnus Gladh
Magnus Gladh

Reputation: 1877

How do I add the css class attribute to a textbox in razor?

I have tried:

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

which isn't working.

Upvotes: 40

Views: 45576

Answers (1)

takepara
takepara

Reputation: 10433

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

A c# string literal does not take single quotes.

'textbox' -> "textbox"

Upvotes: 67

Related Questions