c# - mvc 3 Html.EditorFor add html attribute not work -
i try add html attribute editorfor
@html.editorfor(model => model.username, new { style = "width: 100px" })
but way get
<input id="username" class="text-box single-line" type="text" value="" name="username">
editorfor going overwrite attributes. see html attributes editorfor() in asp.net mvc workarounds.
if need change display of width, , you're not relying on editor templates easiest fix use textboxfor instead
@html.textboxfor(model => model.username, new { style = "width: 100px" })
Comments
Post a Comment