2014-05-05 43 views
0

正如問題所述,我有一個非常簡單的Asp.Net MVC 5應用程序,我正在使用Bootstrap 3.1與以下幫助程序,如何將Bootstrap格式應用於Html.EnumDropDownListFor()?

@this.Html.EnumDropDownListFor(model => model.Status, new { htmlAttributes = new { @class = "form-control" } })

但是,該控件的格式與在同一頁上的文本框不同。我只是使用錯誤的CSS類,或者我錯過了什麼?

回答

9

無需htmlAttributes,你可以只通過一個匿名對象作爲第二個參數EnumDropDownListFor

@Html.EnumDropDownListFor(model => model.Status, new { @class = "form-control" }) 
+2

謝謝,工作就像一個魅力。我只添加了'htmlAttributes',因爲腳手架生成的所有文本框都有它。 –

相關問題