twitter-bootstrap 是否有使用 ASP.NET MVC 5 Html.EditorFor() 和 Bootstrap 3.0 的解决方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18386234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a solution for using ASP.NET MVC 5 Html.EditorFor() and Bootstrap 3.0?
提问by Dan Sorensen
Question:
问题:
Is there a way to make the ASP.NET MVC 5 Html.EditorFor() form helpers work with the changed Bootstrap 3 form syntax.*?
有没有办法让 ASP.NET MVC 5 Html.EditorFor() 表单助手使用更改后的Bootstrap 3 表单语法.*?
Discussion(of what I have looked into already):
讨论(关于我已经研究过的内容):
It appears there are a many SO questions regarding hacks to override the built in MVC helpers. In general, it doesn't look like there is a supported solution to modify the helper HTML. (please correct me if I'm wrong)
似乎有很多关于 hacks 的 SO 问题来覆盖内置的 MVC 帮助程序。通常,看起来没有支持的解决方案来修改帮助程序 HTML。(如果我错了,请纠正我)
Therefore, is it possible to build a shim CSS file that adapts the Helper's 2.3.x HTML to the look of the Bootstrap 3 form CSS? It seems that most other aspects of MVC 5 are Bootstrap 3 compatible except for the auto form fields.
因此,是否可以构建一个 shim CSS 文件,使 Helper 的 2.3.x HTML 适应 Bootstrap 3 表单 CSS 的外观?除了自动表单字段外,MVC 5 的大多数其他方面似乎都与 Bootstrap 3 兼容。
The benefit of a CSS shim, is that it could be removed when ASP.NET MVC is updated to support the newer Bootstrap syntax natively.
CSS shim 的好处是,当更新 ASP.NET MVC 以支持较新的 Bootstrap 语法时,它可以被删除。
*I acknowledge that ASP.NET MVC 5 is still in beta and has been developed for Bootstrap 2.3.x since 3.0 was also in beta at the time.
*我承认 ASP.NET MVC 5 仍处于测试阶段,并且已经为 Bootstrap 2.3.x 开发,因为当时 3.0 也处于测试阶段。
回答by dave heywood
There is now a MS solution for the MVC helpers.
现在有一个针对 MVC 助手的 MS 解决方案。
It's currently Pre-release, but MVC5.1 has
它目前是Pre-release,但 MVC5.1 有
MVC 5.1 is released and has
MVC 5.1 已发布并具有
Bootstrap support in views
We now allow passing in html attributes in EditorFor as an anonymous object
视图中的 Bootstrap 支持
我们现在允许将 EditorFor 中的 html 属性作为匿名对象传递
Example code...
示例代码...
@Html.EditorFor(model => model, new { htmlAttributes = new { @class = "form-control" }, })
More info on this here.... http://www.asp.net/visual-studio/overview/2013/aspnet-and-web-tools-20132-preview-for-visual-studio-2013-release-notes#mvcbootstrap
.. and install instructions here... http://blogs.msdn.com/b/webdev/archive/2013/12/09/asp-net-and-web-tools-2013-2-preview-for-visual-studio-2013.aspx
..并在此处安装说明... http://blogs.msdn.com/b/webdev/archive/2013/12/09/asp-net-and-web-tools-2013-2-preview-for-visual -studio-2013.aspx
回答by gumaflux
TwitterBootstrapMVC looks like a good abstraction over Bootstrap 3 - great with the Fluent API, BUT sending credit card details for a trial? Nope.
TwitterBootstrapMVC 看起来像是对 Bootstrap 3 的一个很好的抽象 - 非常适合 Fluent API,但是发送信用卡详细信息进行试用?不。
回答by Dmitry Efimenko
TwitterBootstrapMVCis a library of html helpers, main focus of which is to simplify writing html related to Twitter Bootstrap forms.
TwitterBootstrapMVC是一个 html helper 库,其主要重点是简化与 Twitter Bootstrap 表单相关的 html 的编写。
As of today it works with Twitter Bootstrap 2 syntax. However, support for Twitter Bootstrap 3 will be released shortly.
截至今天,它适用于 Twitter Bootstrap 2 语法。但是,很快就会发布对 Twitter Bootstrap 3 的支持。
If you used helpers from tihs library, transition from v2 to v3 should be painless.
如果您使用 tihs 库中的助手,从 v2 到 v3 的转换应该是轻松的。
Disclaimer: I'm the author of TwitterBootstrapMVC
The BMVC for Bootstrap 3 is not free.
免责声明:我是 TwitterBootstrapMVC 的作者
Bootstrap 3 的 BMVC 不是免费的。

