我有添加css類到HTML.EditorFor()的問題。我在網上搜索是否有人遇到同樣的問題,但我找不到任何東西。HTML.EditorFor添加類不工作
你能幫我嗎?所以,它沒有問題關於CSS沒有定義的類,它是,但簡單地說,它沒有添加到輸入字段。 這是鑑於代碼:
@model eVinogradarstvo.Models.DetaljiViewModel
@{
ViewBag.Title = "Edit";
}
@using (Html.BeginForm("PromijeniPodatke", "KorisnikDetalji", FormMethod.Post, new { enctype = "multipart/form-data",@class="form-horizontal" }))
{
@Html.AntiForgeryToken()
<div class="col-sm-12">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.kd.id)
@Html.HiddenFor(model => model.kd.korisnik_id)
@Html.HiddenFor(model => model.kd.slika)
@Html.HiddenFor(model => model.kd.dokument_id)
<table class="table table-responsive">
<tr>
<td>Slika profila</td>
<td><input type="file" name="uploadImages" class="input-files" /></td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.ime)</td>
<td>
@Html.EditorFor(model => model.kd.ime, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.kd.ime)
</td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.prezime)</td>
<td>
@Html.EditorFor(model => model.kd.prezime, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.kd.prezime)
</td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.adresa)</td>
<td>
@Html.EditorFor(model => model.kd.adresa, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.kd.adresa)
</td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.grad)</td>
<td>
@Html.EditorFor(model => model.kd.grad)
@Html.ValidationMessageFor(model => model.kd.grad)
</td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.drzava)</td>
<td>
@Html.EditorFor(model => model.kd.drzava)
@Html.ValidationMessageFor(model => model.kd.drzava)
</td>
</tr>
<tr>
<td>@Html.DisplayNameFor(model => model.kd.datum_rodenja)</td>
<td>
@Html.EditorFor(model => model.kd.datum_rodenja)
@Html.ValidationMessageFor(model => model.kd.datum_rodenja)
</td>
</tr>
<tr>
<td>Mjerna jedinica težine</td>
<td>
@Html.DropDownListFor(model => model.kd.mj_tezine, new SelectList(Model.DDLtezina, "vrijednost", "opis"))
@Html.ValidationMessageFor(model => model.kd.mj_tezine)
</td>
</tr>
<tr>
<td>Mjerna jedinica tekućine</td>
<td>
@Html.DropDownListFor(model => model.kd.mj_tekucine, new SelectList(Model.DDLtekucina, "vrijednost", "opis"))
@Html.ValidationMessageFor(model => model.kd.mj_tekucine)
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Spremi" class="btn btn-default" /></td>
</tr>
</table>
</div>
}
有什麼建議?
看到這個 [http://stackoverflow.com/questions/4576209/asp-net-mvc-3-razor-adding-class-to-editorfor] [1] [1]:http://stackoverflow.com/questions/4576209/asp-net-mvc-3-razor-adding-class-to-editorfor –
我已經看到了這個,我的語法是正確的。我已經嘗試了除了用jquery添加類之外的所有東西......如果我必須動態地添加類時它沒有任何意義......這可能是某種錯誤或某種東西?或者我錯過了一些東西...... – Veki
@Veki所以你已經創建了一個自定義編輯器模板作爲該問題中接受的答案說?你能爲你的問題添加代碼嗎? – Rhumborl