在傳統webForm中,輸入框的這樣的:
<input id="userName" name="userName" type="text" value="" />
而在mvc中,可以寫成這樣
@Html.TextBoxFor(m => m.userName)
以上兩句是一樣的,那么如何在mvc中的@Html.TextBoxFor(m => m.userName)輸入框添加css樣式呢?
@Html.TextBoxFor(m => m.userName,new {@class="main",@style="width:20px;"})
上面一句就等於
<input class="main" id="userName" name="userName" style="width:20px;" type="text" value="" />