I have to pass two dimensional array to the page method written at code behind of the web page in asp.net I have a variable objList
as a two dimensional array. I used following code for achieving this with no success and page method is not called.
JAVASCRIPT
function BindTable(objList) { $.ajax( { url: "CompCommonQues.aspx/SaveData", contentType: "application/json; charset=utf-8", dataType: "json", type: "POST", data: { data: objList }, success: function (data) { //Success code here }, error: function () { } }); }
CODE BEHIND .CS File
[WebMethod] public static string SaveData(string[,] data) { string[,] mystring = data; return "saved"; }
There is method like JSON.stringify(objList) to pass the json array to code behind but couldn't implement this. A simple call wihtout array working for me like
data: "{ 'data':'this is string' }",
and in code behind
[WebMethod] public static string SaveData(string data) { string mystring = data; return "saved"; }
There is problem in passing data
. Can you assist me how to pass it for arrays?