ASP.NET MVC 3 Razor - Adding class to EditorFor

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

    Using jQuery, you can do it easily:

    $("input").addClass("class-name")
    

    Here is your input tag

    @Html.EditorFor(model => model.Name)
    

    For DropDownlist you can use this one:

    $("select").addClass("class-name")
    

    For Dropdownlist:

    @Html.DropDownlistFor(model=>model.Name)
    

提交回复
热议问题