ASP.NET MVC 3 Razor - Adding class to EditorFor

后端 未结 16 2080
长情又很酷
长情又很酷 2020-11-27 11:09

I\'m trying to add a class to an input.

This is not working:

@Html.EditorFor(x => x.Created, new { @class = \"date\" })
16条回答
  •  借酒劲吻你
    2020-11-27 11:46

    You can't set class for the generic EditorFor. If you know the editor that you want, you can use it straight away, there you can set the class. You don't need to build any custom templates.

    @Html.TextBoxFor(x => x.Created, new { @class = "date" }) 
    

提交回复
热议问题