This project is read-only.

Post ViewModel using KO.js

Topics: Writing modules
Nov 30, 2013 at 1:23 AM

Im using Knockout JS to post data in controller, but I always receive null value even I passed values in KO
public JsonResult saveMall(MallRecord mallRecord)
   //mallRecord is always null

var mallViewModel =
    Mall_Id: self.Mall_Id ,
    Mall_Name: self.Mall_Name

            url: '/mall/saveMall',
            cache: false,
            type: 'POST',
            datatype: "json",
            data: {
                __RequestVerificationToken: token,
                Mall: ko.toJSON(mallViewModel)
            success: function (data) {
But if I tried to change the parameter datatype of my controller to:
public JsonResult saveMall(int mallID, string mallName)
I can get the right value I passed, I cant list all the parameters in the Controller because I have many fields to passed.

Thank You