加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 在mvc4中的下拉列表更改事件中提交表单

发布时间:2020-12-16 03:39:51 所属栏目:asp.Net 来源:网络整理
导读:这是我的代码 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 Dictionarys
这是我的代码

<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>

我的问题是如何在选择更改下拉列表时提交表单

解决方法

你可以使用jQuery.给下拉列表一个id,就像这样.

<div id="pro_pag2">
 @using (Html.BeginForm("Product",new { }))
      {
           @Html.DropDownList("PageSize",new SelectList(new Dictionary<string,string> {...},new { @class = "pro_pag_tf1",id = "pagesizelist" })
      }
 </div>

然后使用jQuery提交其父表单

$('#pagesizelist').on('change',function(event){
    var form = $(event.target).parents('form');

    form.submit();
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读