【发布时间】:2016-08-25 13:28:09
【问题描述】:
如何在编辑器模板上应用 bootstrap 样式
@Html.EditorFor(model => model.AddressDetails)
我尝试添加 htmlAttributes,如下所示
@Html.EditorFor(model => model.AddressDetails, new { htmlAttributes = new { @class = "col-md-4 col-md-4 col-md-4 bounceIn" }, })
model.AddressDetails 有多个属性,我需要在多行中显示 3 列。
public class AddressDetails
{
[Required]
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string AddressLine3 { get; set; }
public string AddressLine4 { get; set; }
public string AddressLine5 { get; set; }
public string AddressLine6 { get; set; }
public string City { get; set; }
public string Country { get; set; }
但结果就像第一行有 3 列,而下一行则分散在各处。对齐错误。
我认为我编码的方式是错误的。我正在使用 Bootstrap v3.1.1
【问题讨论】:
-
您已标记此 MVC-4,但仅在 MVC-5.1 或更高版本中支持在
EditorFor()中添加 html 属性 -
我应用 html 属性的方式可能有问题。在 MVC 4 中我如何应用 html 属性?
-
@Html.TextBoxFor(m => m.AddressDetails, new { @class = "col-md-4 col-md-4 col-md-4 bounceIn" }) -
我试过这个,但宽度仅适用于模型中的前 3 个属性。之后对齐是错误的。第五个属性 addressline5 不在第二列的正下方。我的意思是文本框控件不适合第二列
-
哪 5 个属性? - 您显示的所有代码都是针对一个元素的。
标签: css asp.net-mvc twitter-bootstrap asp.net-mvc-4 bootstrap-modal