将bootstrap类属性添加到editorformodel ASP.net MVC

时间:2016-02-10 20:05:15

标签: asp.net asp.net-mvc editorformodel

是否可以向EditorForModel添加bootstrap类属性? 该模型生成4个字段但它们没有正确对齐。我试图添加form-control类,但它会在每个字段中添加属性。

这是我添加表格的方式:

 @using (Html.BeginForm())
    {
        <fieldset>
            @Html.AntiForgeryToken()
            <legend>@ViewBag.Title</legend>
            @Html.EditorForModel(new { htmlAttributes = new { @class = "form-control" }})
            <p><input type="submit" value="Save" /></p>
        </fieldset>

    }

在页面源

中添加这个是什么
 <form action="/Products/Edit/1" method="post">    
    <fieldset>
            <input name="__RequestVerificationToken" type="hidden" value="eIwHZW5P2wPCTWgcqYe9SH2Ad_rKuYNWgvvplsqxo7vYLGXzaXlVKR5pPrjVsag7lRmUsm1M-r3sZYDQyThLL_1o1PQUKnKgbCuI88NwQMQ1" />
            <legend>Edit</legend>
            <input class="form-control" data-val="true" data-val-number="The field ProductID must be a number." data-val-required="The ProductID field is required." id="ProductID" name="ProductID" type="hidden" value="1" /><div class="editor-label"><label for="ProductName">Product Name</label></div>
    <div class="editor-field"><input class="form-control text-box single-line" data-val="true" data-val-required="Product name is required." id="ProductName" name="ProductName" type="text" value="chai" /> <span class="field-validation-valid" data-valmsg-for="ProductName" data-valmsg-replace="true"></span></div>
    <div class="editor-label"><label for="SupplierID">SupplierID</label></div>
    <div class="editor-field">

0 个答案:

没有答案