我已尝试使用VS2012实现Twitter Bootstrap到MVC4的许多教程,同时仍尝试保留身份验证代码(即使用Internet应用程序)。
我的问题是,当我使用脚手架来完成我定义的模型的所有CRUD页面时,它不会使用twitter引导程序格式化。
以下是生成的代码:
<div class="editor-label">
@Html.LabelFor(model => model.lastName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.lastName)
@Html.ValidationMessageFor(model => model.lastName)
输出是一个正常的编辑框,而不是带有蓝色轮廓的漂亮的推文框等......
所以我试过了:
@Html.TextBox("Test","",new {@class="form-control"})
并且完美呈现......所以我尝试了:
@Html.EditorFor(model => model.lastName, new { @class = "form-control" })
随后它无效。
请有人建议我如何解决这个问题,或者我可以在哪里下载与MVC4集成的Twitter-bootstrap的预制模板,这样我就可以开始编程了。
我可以提供任何其他所需的代码。
提前致谢
答案 0 :(得分:4)
那是因为你正在使用的方法
@Html.EditorFor( Expression<Func<TModel, TValue>> expression, object additionalViewData )
不像@ Html.Textbox-Helper那样期待“htmlAttributes”。
您可以使用
@Html.TextBoxFor( model => model.lastname, new { @class = "form-control" })