i try to passing javascript array to code-behind using object in code-behind, now i should get each value
[System.Web.Services.WebMethod]
public static void getData(object[] data)
{
...
}
this is array from javascript :
var data = [["5","John"],["6","Marteen"]];
after i pass into code-behind :
data {object[137]}
--[0] {object[1]}
----[0] Count = 8
------[0] {[id, 5]}
------[1] {[Name, John]}
i have to get ID and Name, i can't simply read like javascript, ex : data[0][0]["Name"] = "John";
now i just try to read using foreach and i still can't get the value
foreach (object[] item in data)
{
var array = (object[])item;
foreach (var str in array)
{
/*how to get the value*/
}
}
so how should i do to get that value using index?
thanks before
JavaScript array in server-side is nothing but a plain string. Its unstructured data. To get your object structure back you need to define corresponding C# class. and then as Sayse suggested use Json serializer, something like JSON.NET http://www.newtonsoft.com/json .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.