我有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.Statu
和model => model.Name
表达式分配给我的模型。但是,无法正确捕获带有表达式@Html.TextBoxFor
的{{1}}的值,当我在控制器端收到模型时,我可以看到model => model.Quantity
设置为 0 。是什么原因造成的?
谢谢。