I need to pass a two-dimensional array to a page method written on the code end of a web page in asp.net. I have an objList variable as a two-dimensional array. I used the following code to achieve this without success, and the 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) {
CODE BEHIND.CS File
[WebMethod] public static string SaveData(string[,] data) { string[,] mystring = data; return "saved"; }
There is a method like JSON.stringify (objList) to pass the json array to the code, but could not implement this. A simple call with an array that works for me as
data: "{ 'data':'this is string' }",
and in code
[WebMethod] public static string SaveData(string data) { string mystring = data; return "saved"; }
Along the way, data passes. Can you help me how to pass it for arrays?
Rajaram shelar
source share