Addind css classes to razor elements

后端 未结 3 812
无人共我
无人共我 2021-01-12 03:03

In razor if I had something like:

@Html.EditorFor(model => model.name) or even: @Html.CheckBoxFor(m => m.RememberMe)

How woul

3条回答
  •  既然无缘
    2021-01-12 03:25

    Because EditorFor isn't type-specific, you can't use it on those.

    For CheckBoxFor, you can use:

    @Html.CheckBoxFor(m => m.RememberMe, new { @class = "myClass", id = "myID" })
    

    Note the @ before class because that's a reserved keyword in C#

提交回复
热议问题