Change id attribute of an html.editorfor helper in MVC4 with Razor

前端 未结 4 682
一个人的身影
一个人的身影 2021-01-01 02:16

I have looked through some various answers related to this but all were for mvc3 or not for Razor.

I have a single page that has multiple forms, in partial views, th

4条回答
  •  醉梦人生
    2021-01-01 03:08

    Alternatively you can add htmlAttributes

    @Html.EditorFor(Model => Model.myField, new { htmlAttributes = new { @class = "form-control", @id = "txtMyField" } })
    

提交回复
热议问题