表单控件类不适用于asp.net mvc表单

时间:2015-10-30 05:01:45

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

@model RepoPatternDemo.Models.Phone
@{
    ViewBag.Title = "Create";
}
<h2>Create</h2>
<form role="form" method="POST" class="form-horizontal" id="registration" enctype="multipart/form-data">
    @Html.AntiForgeryToken()
    <div class="form-horizontal">
        <h4>Add New Phone</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Model, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-6">
                @Html.EditorFor(model => model.Model, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Model, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Brand, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-6">
                @Html.EditorFor(model => model.Brand, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Brand, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.Picture, new { @class = "control-label col-md-2" })
            <div class="col-md-6">
                @Html.EditorFor(m => m.Picture, new { htmlAttributes = new { @class = "form-control", @type = "file", @accept = "image/*" }, })
                @Html.ValidationMessageFor(m => m.Picture, "", new { @class = "text-danger" })
                <span class="field-validation-valid text-danger" id="PhonePictureError"></span>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-6">
                <input type="submit" value="Create" class="btn btn-primary" />
            </div>
        </div>
    </div>
</form>


<div>
    @Html.ActionLink("Back to List", "Index", null, htmlAttributes: new { @class = "btn btn-primary" })
</div>

0 个答案:

没有答案