如何在asp.net MVC 5的HTML.EditFor中进行操作,当按下输入时,焦点移动到下一个Html.EditFor?
<div class="form-group">
@Html.LabelFor(model => model.Descripcion, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Descripcion, new { htmlAttributes = new { @class = "form-control" , autofocus = "autofocus"} })
@Html.ValidationMessageFor(model => model.Descripcion, "", new { @class = "text-danger" })
</div>
</div>
答案 0 :(得分:1)
在inputs
上使用tabindex
属性。像这样:
@Html.EditorFor(model => model.Descripcion, new { htmlAttributes = new { @class = "form-control" , tabindex = 1 } })
@Html.EditorFor(model => model.Descripcion3, new { htmlAttributes = new { @class = "form-control" , tabindex = 3} })
@Html.EditorFor(model => model.Descripcion2, new { htmlAttributes = new { @class = "form-control" , tabindex = 2 } })
这样,您就可以使用input
按钮更改tab
焦点并使用正确的顺序。