Set the class attribute to Html.EditorFor in ASP.NET MVC Razor View

后端 未结 5 924
时光说笑
时光说笑 2020-12-30 20:03

As you know we can set attributes to actionLink or textBox in razor views but how can we set attributes to @Html.EditorFor, I know the EditorFor is a dynamic el

5条回答
  •  醉酒成梦
    2020-12-30 20:50

    Try this:

    @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
    

提交回复
热议问题