【问题标题】:Bootstrap required attribute in asp.net mvc razor viewasp.net mvc razor 视图中的引导必需属性
【发布时间】:2015-03-16 10:18:25
【问题描述】:

我需要使用 required 属性,所以字段不能为空

   <input type="text" class="form-control" id="inputName" required>

在剃刀视图中,更具体地说,在本例中

  @Html.EditorFor(model => model.exclure.libelle, new { htmlAttributes = new { @class = "form-control" } })

【问题讨论】:

  • 你可以在模型中设置libelle吗?

标签: asp.net asp.net-mvc twitter-bootstrap razor


【解决方案1】:

您可以通过这种方式在htmlAttributesTextBoxFor() 中指定:

@Html.TextBoxFor(m=>m.exclure.libelle,new{ @class = "form-control",required="required" })

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 2011-03-11
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多