为什么Enter键不考虑标签索引?

时间:2018-10-03 14:12:06

标签: html asp.net-mvc razor tabindex

这是我的cshtml文件:

@using System.Web.Mvc;
@using Kendo.Mvc.UI;
@using System;
@using System.Data;
@using System.Collections.Generic;
@using System.Text;

@model My.Name.Space.Models.SomeObject

@{
    ViewBag.Title = "My Title";
    Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";
}

<div id="dv3" class="scrollarea">
    @using (Ajax.BeginForm("dv3", "", new AjaxOptions() { HttpMethod = "Post" }, new { id = "frmP3" }))
    {
        @Html.AntiForgeryToken()

        <div>
            @(Html.TextBoxFor(m => m.Field1, new { id = "txt1", @tabIndex = "1" }))
            @(Html.TextBoxFor(m => m.Field11, new { id = "txt11", @tabIndex = "11" }))
            @(Html.TextBoxFor(m => m.Field21, new { id = "txt21", @tabIndex = "21" }))
            <br /><br />
            @(Html.TextBoxFor(m => m.Field2, new { id = "txt2", @tabIndex = "2" }))
            @(Html.TextBoxFor(m => m.Field12, new { id = "txt12", @tabIndex = "12" }))
            @(Html.TextBoxFor(m => m.Field22, new { id = "txt22", @tabIndex = "22" }))
            <br /><br />
            @(Html.TextBoxFor(m => m.Field3, new { id = "txt3", @tabIndex = "3" }))
            @(Html.TextBoxFor(m => m.Field13, new { id = "txt13", @tabIndex = "13" }))
            @(Html.TextBoxFor(m => m.Field23, new { id = "txt23", @tabIndex = "23" }))
            <br /><br />
            @(Html.TextBoxFor(m => m.Field4, new { id = "txt4", @tabIndex = "4" }))
            @(Html.TextBoxFor(m => m.Field14, new { id = "txt14", @tabIndex = "14" }))
            @(Html.TextBoxFor(m => m.Field24, new { id = "txt24", @tabIndex = "24" }))
        </div>
    }
</div>

我的控制器同样简单:

public ActionResult View3()
{
    return View(base.GetViewPath("3"), new SomeObject());
}

我运行该应用程序并导航至此页面,然后将焦点设置为txt1。当我按Tab时,焦点将从txt1变为txt2。完美。

如果我按Enter,焦点将从txt1变为txt11。不正确应该使用下一个最接近的Tab索引转到控件。

为什么Enter不遵循与Tab相同的顺序?

0 个答案:

没有答案