如果最小元素为null,则mvc跳过最大元素

时间:2019-01-18 14:00:31

标签: model-view-controller tab-ordering

在MVC5 c#实体框架项目上工作,在该项目中,用户正在输入一系列40个“最小值/最大值”。如果“最小”字段未填充或为空,则用户希望TAB跳过“最大”文件,然后转到“下一个最小”元素。这是我们正在转换为MVC / Entity Framework的当前应用程序中的行为,并且如果可能的话,希望复制该行为。

该代码示例每行的Min / Max字段具有3列。制表符顺序位于该列下方,并使用EditorFor语句上的tabindex来使制表符顺序起作用。

如果可能的话,我们只希望它跳过“最大”文件并转到下一个“最小”字段。感谢您的帮助或指导。

 <div class="form-horizontal">

    <div class="form-group">
        @Html.LabelFor(model => model.F_MNI3, htmlAttributes: new { @class = "control-label col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNI3, new { htmlAttributes = new { @class = "form-control", tabindex = 2 } })
            @Html.ValidationMessageFor(model => model.F_MNI3, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @*  @Html.EditorFor(model => model.A_NAME, new { htmlAttributes = new { @onchange = "OnChangeEvent(this)", tabindex = 2 } })  *@
            @Html.EditorFor(model => model.F_MXI3, new { htmlAttributes = new { @onchange = "OnChangeEvent(this)", @class = "form-control", tabindex = 3 } })
            @Html.ValidationMessageFor(model => model.F_MXI3, "", new { @class = "text-danger" })
        </div>

        @Html.LabelFor(model => model.F_MNN8, htmlAttributes: new { @class = "control-label   col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNN8, new { htmlAttributes = new { @class = "form-control", tabindex = 22 } })
            @Html.ValidationMessageFor(model => model.F_MNN8, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXN8, new { htmlAttributes = new { @class = "form-control", tabindex = 23 } })
            @Html.ValidationMessageFor(model => model.F_MXN8, "", new { @class = "text-danger" })
        </div>


        @Html.LabelFor(model => model.F_MNDUST, htmlAttributes: new { @class = "control-label    col-md-3" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNDUST, new { htmlAttributes = new { @class = "form-control", tabindex = 50 } })
            @Html.ValidationMessageFor(model => model.F_MNDUST, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXDUST, new { htmlAttributes = new { @class = "form-control", tabindex = 51 } })
            @Html.ValidationMessageFor(model => model.F_MXDUST, "", new { @class = "text-danger" })
        </div>

    </div>



    <div class="form-group">
        @Html.LabelFor(model => model.F_MNI2HALF, htmlAttributes: new { @class = "control-label col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNI2HALF, new { htmlAttributes = new { @class = "form-control", tabindex = 4 } })
            @Html.ValidationMessageFor(model => model.F_MNI2HALF, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXI2HALF, new { htmlAttributes = new { @class = "form-control", tabindex = 5 } })
            @Html.ValidationMessageFor(model => model.F_MXI2HALF, "", new { @class = "text-danger" })
        </div>

        @Html.LabelFor(model => model.F_MNN10, htmlAttributes: new { @class = "control-label   col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNN10, new { htmlAttributes = new { @class = "form-control", tabindex = 24 } })
            @Html.ValidationMessageFor(model => model.F_MNN10, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXN10, new { htmlAttributes = new { @class = "form-control", tabindex = 25 } })
            @Html.ValidationMessageFor(model => model.F_MXN10, "", new { @class = "text-danger" })
        </div>


        @*  @Html.LabelFor(model => model.F_MNCRUSH, htmlAttributes: new { @class = "control-label  col-md-offset-1  col-md-2" }) *@
        @Html.LabelFor(model => model.F_MNCRUSH, htmlAttributes: new { @class = "control-label   col-md-3" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNCRUSH, new { htmlAttributes = new { @class = "form-control", tabindex = 52 } })
            @Html.ValidationMessageFor(model => model.F_MNCRUSH, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXCRUSH, new { htmlAttributes = new { @class = "form-control", tabindex = 53 } })
            @Html.ValidationMessageFor(model => model.F_MXCRUSH, "", new { @class = "text-danger" })
        </div>

    </div>


    <div class="form-group">
        @Html.LabelFor(model => model.F_MNI2, htmlAttributes: new { @class = "control-label col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNI2, new { htmlAttributes = new { @class = "form-control", tabindex = 6 } })
            @Html.ValidationMessageFor(model => model.F_MNI2, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXI2, new { htmlAttributes = new { @class = "form-control", tabindex = 7 } })
            @Html.ValidationMessageFor(model => model.F_MXI2, "", new { @class = "text-danger" })
        </div>

        @Html.LabelFor(model => model.F_MNN16, htmlAttributes: new { @class = "control-label   col-md-1" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNN16, new { htmlAttributes = new { @class = "form-control", tabindex = 26 } })
            @Html.ValidationMessageFor(model => model.F_MNN16, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXN16, new { htmlAttributes = new { @class = "form-control", tabindex = 27 } })
            @Html.ValidationMessageFor(model => model.F_MXN16, "", new { @class = "text-danger" })
        </div>


        @Html.LabelFor(model => model.F_MNDENS, htmlAttributes: new { @class = "control-label    col-md-3" })
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MNDENS, new { htmlAttributes = new { @class = "form-control", tabindex = 54 } })
            @Html.ValidationMessageFor(model => model.F_MNDENS, "", new { @class = "text-danger" })
        </div>
        <div class="col-md-1">
            @Html.EditorFor(model => model.F_MXDENS, new { htmlAttributes = new { @class = "form-control", tabindex = 55 } })
            @Html.ValidationMessageFor(model => model.F_MXDENS, "", new { @class = "text-danger" })
        </div>

      </div>

  </div>

0 个答案:

没有答案