set “id” and “name” for @HtmlEditorFor?

后端 未结 3 1344
[愿得一人]
[愿得一人] 2020-12-16 17:49

I\'m trying to set id and name for @Html.EditorFor, but this isn\'t working:

@H         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 18:01

    EditorFor does not allow for adding htmlAttributes. For the specific types of editors you'll have to use TextBoxFor (or whatever type you're using).

    @Html.TextBoxFor(m => m.value, new { id = "testid1", name="Testname1" })
    

    You can also create a custom editor template for the particular type you're creating an editor for.

提交回复
热议问题