json - Why is the update operation not posting any data? -
i using kendo grid inline editing. when click "update" button, post gets made controller method signature. controller action gets hit, post working.
[httppost] public httpresponsemessage saveaccountadmin(string jsoncompanycontacts)
however post info in update operation never arrives - null.
update: { url: "/company/saveaccountadmin", contenttype: "application/json; charset=utf-8", type: "post", datatype: "json", data: { jsoncompanycontacts: "john doe" } },
here total info source code.
var datasource = new kendo.data.datasource( { batch: false, pagesize: 10, transport: { create: { url: "/company/saveaccountadmin", contenttype: "application/json; charset=utf-8", type: "post", datatype: "json" }, read: { url: "/company/readaccountadmin" }, update: { url: "/company/saveaccountadmin", contenttype: "application/json; charset=utf-8", type: "post", datatype: "json", data: { jsoncompanycontacts: "john doe" } }, //destroy: {}, parametermap: function (data, type) { homecoming kendo.stringify(data); } },
this doesnt work either:
update: { url: "/company/saveaccountadmin", contenttype: "application/json; charset=utf-8", type: "post", datatype: "json", //data: { "jsoncompanycontacts": kendo.stringify({ jsoncompanycontacts: "john doe" }) } data: { "jsoncompanycontacts": "john doe" } }, //destroy: {}, parametermap: function (data, type) { homecoming kendo.stringify(data); }
but works- why?
update: { url: "/company/saveaccountadmin", contenttype: "application/json; charset=utf-8", type: "post", datatype: "json", //data: { "jsoncompanycontacts": kendo.stringify({ jsoncompanycontacts: "john doe" }) } //data: { "jsoncompanycontacts": "john doe" } }, //destroy: {}, parametermap: function (data, type) { homecoming kendo.stringify({ "jsoncompanycontacts": "john doe" }); }
the value not passed controller string. seek using model. might help: mvc3 & json.stringify() modelbinding returns null model
updateyou don't want that. might work in theis 1 case, shooting in foot.
model
public class companycontactmodel { public string companycontacts { get; set; } }
controller signature
public jsonresult saveaccountadmin(companycontactmodel companycontactmodel) ...
better
public jsonresult saveaccountadmin([datasourcerequest]datasourcerequest request, companycontactmodel companycontactmodel) ... update , homecoming , set list if error: modelstate.addmodelerror(string.empty, e.message); datasourceresult result = [your model list].todatasourceresult(request, modelstate); homecoming json(result, jsonrequestbehavior.allowget); }
json asp.net-mvc-3 asp.net-mvc-4 kendo-ui kendo-grid
No comments:
Post a Comment