ASP.NET MVC 3 Razor - Adding class to EditorFor

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

    @Html.EditorFor(m=>m.Created ...) 
    

    does not allow any arguments to be passed in for the Text box

    This is how you can apply attributes.

    @Html.TextBoxFor(m=>m.Created, new { @class= "date", Name ="myName", id="myId" })
    

提交回复
热议问题