control name in TextBoxFor in MVC3

前端 未结 5 1037
孤城傲影
孤城傲影 2020-12-11 04:45

Is it possible to control the name attribute of say a text boxt when using TextBoxFor?

this code in the view

@Html.TextBoxFor(m => m.SearchParams         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 05:28

    TextBoxFor doesn't allow the name attribute to be set. This workaround:

    @Html.EditorFor(m => m.UserName, null, "user_name")
    

    outputs:

    
    

提交回复
热议问题