Ajax.BeginForm无法正确提交表单

时间:2019-09-04 08:13:31

标签: c# ajax asp.net-mvc razor asp.net-ajax

我有Ajax.BeginForm支持的表格。表单中有两个输入字段,另外还有一个隐藏字段。

 @using (Ajax.BeginForm("InsertMissingItems","MissingItem", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "itemList" }))
    {
        @Html.HiddenFor(model => model.Statu, new { id = "hdnStatu" })
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="form-horizontal">
                    <div class="form-group" lang="tr">
                        @Html.Label("Ürün Adı", new { @class = "control-label col-md-2 text-left" })
                        <div class="col-md-4">
                            @Html.DropDownListFor(model => model.Name,
                                new List<SelectListItem> {
                                    new SelectListItem {
                                       Text="CSS",
                                       Value="1",
                                    },
                                    new SelectListItem {
                                       Text="HTML",
                                       Value="2",
                                    },
                                }, "Kategori Seçiniz", new { @class = "form-control" })
                        </div>
                    </div>
                    <div class="form-group" lang="tr">
                        @Html.Label("Miktar", new { @class = "control-label col-md-2 text-left" })
                        <div class="col-md-4">
                            @Html.TextBoxFor(model => model.Quantity, new { @class = "form-control", type = "number", min = 1 })
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-4">
                            <button class="btn btn-success col-lg-4" type="submit" id="btnAdd" onclick="return Validation(@((int)Enums.MissingItem.Add))"><i class="fa fa-plus" aria-hidden="true"></i>  Ekle</button>
                        </div>
                    </div>
                </div>
            </div>
    </div>

当我提交表单时,隐藏字段@Html.HiddenFor@Html.DropDownListFor的值被正确捕获,并且这些值通过model => model.Statumodel => model.Name表达式分配给我的模型。但是,无法正确捕获带有表达式@Html.TextBoxFor的{​​{1}}的值,当我在控制器端收到模型时,我可以看到model => model.Quantity设置为 0 。是什么原因造成的?

谢谢。

0 个答案:

没有答案