asp.net mvc - How to add css class and id in @Html.TextBox mvc4 at the same time -
i need add css class , id in @html.textbox mvc4 @ same time. try
@html.textbox("name", new { id = "name"}, new { @class = "text-field" }) but result
<input class="text-field" id="name" name="name" type="text" value="{ id = name }"> i dont need attribute value here.
need
<input type="text" value="" name="name" id="name" class="text-field" />
correct overload method
public static mvchtmlstring textbox( htmlhelper htmlhelper, string name, object value, object htmlattributes ) you want use id htmlattribute, should use in htmlattributes object. correct usage of textbox is:
@html.textbox("name", null, new { id = "name", @class = "text-field" }) if place id in route object, id route value.
Comments
Post a Comment