I have tried:
@Html.TextBoxFor(m => m.UserName, new {@class='textbox'})
which isn't working.
You can set the class with @class="className" but you have to specify actionName, controllerName, FormMethod too because there is no overload of Html. BeginForm that supports setting only html attributes. You can create your own html helper, that does that for you, too. Here is a custom html helper does that.
The HTML class attribute specifies one or more class names for an element. Classes are used by CSS and JavaScript to select and access specific elements. The class attribute can be used on any HTML element. The class name is case sensitive. Different HTML elements can point to the same class name.
Just use a view model. If you are, you can make List<ObjectData> part of it. In your controller, you load up that list (lets call it ObjectDataList ), and send it to your view.
@Html.TextBoxFor(m => m.UserName, new {@class="textbox"})
A c# string literal does not take single quotes.
'textbox' -> "textbox"
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