Autofocus on EditorFor

前端 未结 4 1292
梦谈多话
梦谈多话 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:23

    Using .Net Framework 4.5 and MVC 5, this works for me:

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

提交回复
热议问题