[英]Can I post back more values (e.g. ViewBag or Viewmodel values) when a DropDownListFor is selected?
I have a DropDownListFor that is working fine. 我有一个DropDownListFor正常工作。 It's posting back the correct value as selected by the user. 它回发了用户选择的正确值。 I'm trying to figure out if some of the Viewbag settings in the View can also be posted back to the controller (as query string items eg localhost:44346/Donation/IndexManage?Page=3&PageSize=20&SortOrder=ID). 我试图弄清楚视图中的某些Viewbag设置是否也可以发布回控制器(例如查询字符串项,例如localhost:44346 / Donation / IndexManage?Page = 3&PageSize = 20&SortOrder = ID)。
Using javascript I am triggering the form to submit on change of the DDL items ... all working OK. 使用javascript,我触发了DDL项更改时提交的表单...一切正常。 Any help would be appreciated. 任何帮助,将不胜感激。
@using (Html.BeginForm("IndexManage", "Donation", FormMethod.Get, new { id = "DDL_PageSize" }))
{
<div id="Paging">
Records to Display:
@Html.DropDownListFor(
// 1. Store selected value in Model.Donation.WalkerID;
// when page is rendered after postback,
// take selected value from Model.Donation.WalkerID.
model => model.PageSize,
// 2. Take list of values from Model.Walkers
Model.PageSizeDDL,
// 3. Text for the first 'default' option
@Model.DisplayPageSizeDDL,
//4. A class name to assign to <select> tag
new { @class = "form-control form-control-md g-py-13 pr-0"})
</div>
}
<script type="text/javascript">
$(function () {
$("#PageSize").change(function () {
alert("Triggered by DDL");
$("#DDL_PageSize").submit();
});
});
</script>
尝试这个
@using (Html.BeginForm("ActionName","ControllerName", FormMethod.Get, new { param1 = "param1", param2 = "param2 " }))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.