将焦点移动到下一个HTML.EditFor

时间:2016-08-31 19:44:59

标签: asp.net-mvc

如何在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>

1 个答案:

答案 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焦点并使用正确的顺序。