[英]Asp.Net MVC Razor BootStrap Input Form
Currently I have an Input form like this: 目前我有一个这样的输入表单:
<div class="editor-label">
@Html.LabelFor(model => model.VenueID)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.VenueID)
@Html.ValidationMessageFor(model => model.VenueID)
</div>
I want to convert it to using the following bootstrap code: 我想将其转换为使用以下引导代码:
<div class="form-group">
<label for="inputVenueID" class="col-lg-2 control-label">Venue ID</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputVenueID" placeholder="VenueID">
</div>
</div>
How do I do this, so that I can still use the same Razor
syntax of HTML.LabelFor
/ EditorFor
/ ValidationMessage
etc? 我该怎么做,以便我仍然可以使用
HTML.LabelFor
/ EditorFor
/ ValidationMessage
等相同的Razor
语法?
<div class="form-group">
@Html.LabelFor(model => model.VenueID, new { @class = "sr-only", @for = "txtVenueID" })
@Html.TextBoxFor(model => model.VenueID, new { @class = "form-control", @placeholder = "ID:" , @id="txtVenueID" })
@Html.ValidationMessageFor(model => model.VenueID)
</div>
You can add CSS classes using Razor syntax as shown below. 您可以使用Razor语法添加CSS类,如下所示。 All you need to do is specify the Bootstrap class(es) you want to use.
您需要做的就是指定要使用的Bootstrap类。
<div class="editor-field">
@Html.TextBoxFor(model => model.VenueID, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.VenueID)
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.