Ajax.Beginform oBegin没有向控制器提供更新的数据,它第二次提供更新的数据

时间:2015-10-06 10:39:20

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

我使用Ajax.beginform以及onbegin

   @using (Ajax.BeginForm("NewUser", null, new AjaxOptions { OnSuccess = "UserRoles.onSuccess", OnFailure = "UserRoles.onFailure", HttpMethod = "POST", OnBegin = "return setValues()" }, new { @class = "" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.HiddenFor(model => model.ServiceCentreId)
                    @Html.HiddenFor(model => model.RoleId)
                    @Html.HiddenFor(model => model.ProvinceId)
                    @Html.HiddenFor(model => model.DistrictId)
                    @Html.HiddenFor(model => model.DivisionId)
                    @Html.HiddenFor(model => model.TehsilId)
                    @Html.HiddenFor(model => model.MauzaId)
                    @Html.HiddenFor(model => model.PatwarCircleId)
                    @Html.HiddenFor(model => model.QanoonGoiId)
}

  function setValues() {
            debugger;
            var selectedSCrows = $("#gridSC").jqGrid("getGridParam", "selarrrow");

            for (var i = 0; i < selectedSCrows.length; i++) {
                var rowScData = $("#gridSC").jqGrid('getRowData', selectedSCrows[i]);
                $("#ServiceCentreId").val($("#ServiceCentreId").val() + ";" + rowScData.ServiceCentreId);
            }
            var rolesGridData = UserRoles.getGridData();
            if (typeof (rolesGridData) != "undefined") {
                for (var j = 0; j < rolesGridData.length; j++) {
                    $("#RoleId").val($("#RoleId").val() + ";" + rolesGridData[j].RoleId);
                    $("#ProvinceId").val($("#ProvinceId").val() + ";" + rolesGridData[j].ProvinceId);
                    $("#DivisionId").val($("#DivisionId").val() + ";" + rolesGridData[j].DivisionId);
                    $("#DistrictId").val($("#DistrictId").val() + ";" + rolesGridData[j].DistrictId);
                    $("#TehsilId").val($("#TehsilId").val() + ";" + rolesGridData[j].TehsilId);
                    $("#QanoonGoiId").val($("#QanoonGoiId").val() + ";" + rolesGridData[j].QanoonGoiId);
                    $("#PatwarCircleId").val($("#PatwarCircleId").val() + ";" + rolesGridData[j].PatwarCircleId);
                    $("#MauzaId").val($("#MauzaId").val() + ";" + rolesGridData[j].MauzaId);
                }
            }

            return true;
        }

但我没有在控制器中获得更新的值。我调试了java脚本函数setvalues正在调用但我无法在服务器端接收它。

 [HttpPost]
        public ActionResult NewUser(NewUser newUser)
        {




            return View(newuser);
        }

0 个答案:

没有答案