需要帮助:模型在控制器中为空 [英] Need help : Model is null in the controller

查看:40
本文介绍了需要帮助:模型在控制器中为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我使用下面的代码来实现我的功能,但我没有在控制器中获得该模型。请帮助解决以下问题。



Hi,

I am using the below code to achieve my functionality but i am not getting the model in the controller. Please help on the below issue.

var productCalcaulationModel = {
       ProductId: $('input[attributeName="ProductID"]').val(),
       DealWorkFlowProductID: $('input[attributeName="WorkFlowID"]').val(),
       ExistingTariff: $('input[attributeName="Existing Rate"]').val(),
       CalculationAttributes: '',
       SimpleAttributes: simpleAttributes
   };

   $.ajax({
       url: '/Hermes/Deposit/Edit',
       type: 'POST',
       data: JSON.stringify(productCalcaulationModel),
       datatype: 'json',
       //contentType: "application/json;charset=utf-8",
       success: function (data) {
           PopulateDealWorkflowDepositsTable(data, 'tableDepositDeal', false, -1, -1);
       },
       error: function (x, y, z) {
           alertify.error(genericErrorMessage);
           $('#loaderSelectProducts').css('display', 'none');
       }
   });







 [System.Web.Mvc.HttpPost]
        public JsonResult Edit(ProductCalculationModel model)
        {
//some code here for my functionality and returning the JsonResult

        }










public class ProductCalculationModel
   {
       public int ProductId { get; set; }

       public decimal ProposedTariff { get; set; }

       public decimal ExistingTariff { get; set; }

       public IList<PriceableProductAttribute> CalculationAttributes { get; set; }

       public IList<Attribute> SimpleAttributes { get; set; }

       public string ClientSegment { get; set; }

       public string DepositRowID { get; set; }

       public int DealWorkFlowProductID { get; set; }

       public ProductCalculationModel() { }
   }







我没有从我从ajax Json发送的Edit方法中获取模型。




I am not getting the model in the Edit method which i am sending from the ajax Json.

推荐答案

' input [attributeName =ProductID]')。val(),
DealWorkFlowProductID:
('input[attributeName="ProductID"]').val(), DealWorkFlowProductID:


' input [attributeName =WorkFlowID ]')。val(),
ExistingTariff:
('input[attributeName="WorkFlowID"]').val(), ExistingTariff:


' input [attributeName =Existing Rate]')。val(),
CalculationAttributes:' '
SimpleAttributes:simpleAttributes
};
('input[attributeName="Existing Rate"]').val(), CalculationAttributes: '', SimpleAttributes: simpleAttributes };


这篇关于需要帮助:模型在控制器中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆