【问题标题】:issue with bootstrap styling input types引导样式输入类型的问题
【发布时间】:2014-03-20 00:06:51
【问题描述】:

我正在使用 asp.net mvc-5,并且我正在使用 MVC 模板附带的默认引导程序。我对表单样式有疑问。用于字符串值的 @Html.EditorFor 表单输入显示在正确的 GUI 中,但整数 @Html.EditorFor 没有拾取默认 css,另外我注意到有额外的 CSS 类“.single-line”和“text-盒子”类....

我想要相同的外观和感觉......我做错了什么!

字符串值显示

 <div class="form-group">
   @Html.LabelFor(model => model._Qualification.QualificationTitle, new { @class = "control-label col-md-3" })
      <div class="col-md-6">
        @Html.EditorFor(model => model._Qualification.QualificationTitle)
        @Html.ValidationMessageFor(model => model._Qualification.QualificationTitle)
      </div>
 </div>

int值显示

<div class="form-group">
   @Html.LabelFor(model => model._Qualification.MinCandidates, new { @class = "control-label col-md-3" })
    <div class="col-md-6">      
      @Html.EditorFor(model => model._Qualification.MinCandidates)
      @Html.ValidationMessageFor(model => model._Qualification.MinCandidates)
    </div>
 </div>

还有什么方法可以将类添加到 EditFor

【问题讨论】:

    标签: jquery css asp.net-mvc twitter-bootstrap


    【解决方案1】:

    您将需要使用 TextBoxFor,除非您创建自己的编辑器模板以便传递类信息

    @Html.TextBoxFor(model => model._Qualification.QualificationTitle, new { @class = "form-control" })
    

    【讨论】:

      【解决方案2】:

      或者使用TwitterBootstrapMVC。它有很多你可能会觉得有用的助手。示例:

      @Html.Bootstrap().FormGroup().TextBoxFor(model => model.Property)
      

      免责声明: BMVC 对于 Bootstrap 3 来说不是免费的。 我是BMVC的作者

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-05-28
        • 2020-03-15
        • 2017-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多