MVC4怎么设置@Html.TextBoxFor这样的输入框的css样式

在传统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="" /> 

  

posted @ 2014-05-06 15:13  一夜秋2014  Views(6912)  Comments(0Edit  收藏  举报