ASP.NET MVC 3 Razor - Adding class to EditorFor

后端 未结 16 2105
长情又很酷
长情又很酷 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:54

    You can use:

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

    (At least with ASP.NET MVC 5, but I do not know how that was with ASP.NET MVC 3.)

提交回复
热议问题