html.editorfor css,css - HTML.EditorFor adding class not working - Stack Overflow

作者在使用ASP.NET MVC进行开发时遇到了一个问题:无法将CSS类添加到HTML.EditorFor生成的输入字段上。尽管已经定义了CSS类,但这些类并未成功应用于输入元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have problem with adding css class to HTML.EditorFor(). I was searching on the net if someone had the same problem but I couldn't find anything.

Can you please help me? So, its not problem about css that class is not defined, it is, but simply, its not added to input field.

This is the code in view:

@model eVinogradarstvo.Models.DetaljiViewModel

@{

ViewBag.Title = "Edit";

}

@using (Html.BeginForm("PromijeniPodatke", "KorisnikDetalji", FormMethod.Post, new { enctype = "multipart/form-data",@class="form-horizontal" }))

{

@Html.AntiForgeryToken()

@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)

Slika profila
@Html.DisplayNameFor(model => model.kd.ime)

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

@Html.ValidationMessageFor(model => model.kd.ime)

@Html.DisplayNameFor(model => model.kd.prezime)

@Html.EditorFor(model => model.kd.prezime, new { @class = "form-control" })

@Html.ValidationMessageFor(model => model.kd.prezime)

@Html.DisplayNameFor(model => model.kd.adresa)

@Html.EditorFor(model => model.kd.adresa, new { @class = "form-control" })

@Html.ValidationMessageFor(model => model.kd.adresa)

@Html.DisplayNameFor(model => model.kd.grad)

@Html.EditorFor(model => model.kd.grad)

@Html.ValidationMessageFor(model => model.kd.grad)

@Html.DisplayNameFor(model => model.kd.drzava)

@Html.EditorFor(model => model.kd.drzava)

@Html.ValidationMessageFor(model => model.kd.drzava)

@Html.DisplayNameFor(model => model.kd.datum_rodenja)

@Html.EditorFor(model => model.kd.datum_rodenja)

@Html.ValidationMessageFor(model => model.kd.datum_rodenja)

Mjerna jedinica težine

@Html.DropDownListFor(model => model.kd.mj_tezine, new SelectList(Model.DDLtezina, "vrijednost", "opis"))

@Html.ValidationMessageFor(model => model.kd.mj_tezine)

Mjerna jedinica tekućine

@Html.DropDownListFor(model => model.kd.mj_tekucine, new SelectList(Model.DDLtekucina, "vrijednost", "opis"))

@Html.ValidationMessageFor(model => model.kd.mj_tekucine)

}

Any suggestions?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值