I need to assign multiple classes to an MVC TextBox HTML helper, so it functions the same as when assigning multiple classes to an HTML element.
i.e.: <div class="class1, class2"></div>
The following does not work properly:
@Html.TextBoxFor(x => x.Name, new { @class = "class1, class2" })
Note: I need to add both class names to a single element in order to trigger different jQuery functions. Any advice would be greatly appreciated.
Close:
@Html.TextBoxFor(x => x.Name, new { @class = "class1 class2" })
...produces the following HTML:
<input class="class1 class2" data-val="true" data-val-required="Name is required" id="Name" name="Name" type="text" value="">
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