C# MVC No submit pass object between views

前端 未结 1 1732
时光说笑
时光说笑 2021-01-21 21:06

I am sorry for my typos.I am working on proof of concept C# ASP.NET MVC application where I need to pass data between two views when there is no post and get. One view launches

相关标签:
1条回答
  • 2021-01-21 21:39

    Why don't you use the AJAX for pass the data?

        function ChargeViewModel() {
            this.Description ='';
            this.IsMultipleMatch =false;
    
        }
    
        var chargeViewModel= new ChargeViewModel();
        var data = JSON.stringify({ 'chargeViewModel': chargeViewModel });
    
        $.ajax({
            contentType: 'application/json; charset=utf-8',
            dataType: 'html',
            type: 'POST',
            url: '@Url.Action("LoadLoanChargeDescriptions", "LoanChargeController")',
            data: data,
            success: function (result) {
               //result will be your partial page html output
            },
            failure: function (response) {
    
            }
        });
    

    Then you have to change the controller like this:

    public ActionResult LoadLoanChargeDescriptions(ChargeViewModel chargeViewModel)
      {
          // get data here and pass/work on
          return View("_PartialMultipleMatchPopup", null);
      }
    

    Let me know you have queries..

    0 讨论(0)
提交回复
热议问题