参数传递在MVC控制器中



我在控制器中具有以下动作率

            [HttpGetAttribute]
    public ActionResult _UpdateAlertNote(int recordId)
    {
        DealActionUpdateAlertNoteViewModel vm = new DealActionUpdateAlertNoteViewModel();
        dtDeal_v10_r1.Manager objMan = new dtDeal_v10_r1.Manager(ref mobjSecurity);
        dtDeal_v10_r1.Deal objDeal = default(dtDeal_v10_r1.Deal);
        objDeal = objMan.GetDealObject(recordId, true);
        vm.Message = objDeal.AlertMessage;
        vm.IsDefaultStyle = objDeal.Alert_UseDefaultStyle;
        vm.BackgroundColor = objDeal.Alert_BackgroundColor;
        vm.FontColor = objDeal.Alert_FontColor;
        vm.DealId = recordId;
        return PartialView(vm);
    }

也以下ActionResult

            [HttpPost]
    public ActionResult _UpdateAlertNote(DealActionUpdateAlertNoteViewModel vm)
    {
        dtDeal_v10_r1.Manager objMan = new dtDeal_v10_r1.Manager(ref mobjSecurity);
        objMan.UpdateAlertMessage(vm.DealId, vm.Message, vm.IsDefaultStyle, vm.FontColor, vm.BackgroundColor);
        return this.PartialView("_action", vm.DealId);
    }

当我执行此代码时,帖子中的"交易"呈0。

我检查了GET,并且交易所存储在vm.dealid中,但未传递到邮政方法中。

我不确定为什么没有通过,有人可以帮助我解决这个问题。

****编辑json添加了***

    DealerSocket.TakeAction.updateDealAlertNote = function () {
var controller = "/DealAction/_UpdateAlertNote?mDeal_ID=";
var formId = "_UpdateDealAlertNoteFormElement";
DealerSocket.TakeAction.PostActionAndRefresh(formId, controller);

};

当您将HTML表单元素发布到后操作时,您需要确保将您传递给视图的值存储在表单元素中。

在您的这种情况下,您将需要以下内容:

<input type="hidden" value="@vm.DealId" /> 

在您要发布到操作的<form>标签中。

只有<form>标签内的元素将被序列化并发送到操作。

最新更新