Autofocus on EditorFor

前端 未结 4 1148
梦谈多话
梦谈多话 2021-01-11 22:51

I would like to autofocus on an editorfor in my application, but I can\'t seem to do that. I have successfully used autofocus on a textbox, but I would like to use an editor

4条回答
  •  孤街浪徒
    2021-01-11 23:34

    You put the autofocus attribute in the wrong spot.

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

    Try this instead:

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

提交回复
热议问题