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

前端 未结 4 684
一个人的身影
一个人的身影 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 02:55

    Change your helper from EditorFor to TextBoxFor the EditorFor, doesn't have a overload to override html properties

    Change this

    @Html.EditorFor(model => model.Name,  new {id = "PersonName"})
    

    To this

    @Html.TextBoxFor(model => model.Name,  new {id = "PersonName"})
    

提交回复
热议问题