这是我的代码
<div id="pro_pag2">
@using (Html.BeginForm("Product", "Main", new { customerId = mdlLoginData.CustomerID, GroupID = ViewBag.GroupID, page = 1 }, FormMethod.Post, new { }))
{
@Html.DropDownList("PageSize", new SelectList(new Dictionary<string, string> {{ "18", "18" }, { "12", "12" },{ "6", "6" } }, "Key", "Value"), new { @class = "pro_pag_tf1" })
}
</div>
我的问题是如何在选择更改下拉列表时提交表单
答案 0 :(得分:14)
您可以使用jQuery。给下拉列表一个id,就像这样。
<div id="pro_pag2">
@using (Html.BeginForm("Product", "Main", new { customerId = mdlLoginData.CustomerID, GroupID = ViewBag.GroupID, page = 1 }, FormMethod.Post, new { }))
{
@Html.DropDownList("PageSize",
new SelectList(new Dictionary<string, string> {...}, "Key", "Value"),
new { @class = "pro_pag_tf1", id = "pagesizelist" })
}
</div>
然后使用jQuery提交其父表单
$('#pagesizelist').on('change', function(event){
var form = $(event.target).parents('form');
form.submit();
});