Javascript can read the list using for loop. e.g
[WebMethod]
public static List<EmpName> GetData(int startIndex, int maximumRows, string sort, string filter)
{
var emp = objClient.GetData(startIndex, maximumRows, sort, filter);
List<EmpName> lstEmp = new List<EmpName>();
foreach (var item in emp)
{
EmpName objEmp = new EmpName();
objEmp.ID = item.ID;
objEmp.Name = item.Name;
lstEmp.Add(objEmp);
}
return lstEmp;
}
Javascript:
function ReadList(lstEmp)
{
for(var i=0;i<lstEmp.length;i++)
{
alert(lstEmp[i].ID+" "+ lstEmp[i].Name);
}
}
I want to create a list in javascript i.e List to perform various operation at client side how it can be achieved?
Javascript can read the list using for loop. e.g
[WebMethod]
public static List<EmpName> GetData(int startIndex, int maximumRows, string sort, string filter)
{
var emp = objClient.GetData(startIndex, maximumRows, sort, filter);
List<EmpName> lstEmp = new List<EmpName>();
foreach (var item in emp)
{
EmpName objEmp = new EmpName();
objEmp.ID = item.ID;
objEmp.Name = item.Name;
lstEmp.Add(objEmp);
}
return lstEmp;
}
Javascript:
function ReadList(lstEmp)
{
for(var i=0;i<lstEmp.length;i++)
{
alert(lstEmp[i].ID+" "+ lstEmp[i].Name);
}
}
I want to create a list in javascript i.e List to perform various operation at client side how it can be achieved?
Share asked Apr 19, 2011 at 3:44 Ulhas TuscanoUlhas Tuscano 5,62015 gold badges59 silver badges90 bronze badges1 Answer
Reset to default 3There are multiple ways to create a List in JS.
The easiest one being
var l = [];
l[0] = "a";
l[1] = 1;
another way todo so is
var l= [1,"as",func];
refer W3Schools
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742291234a4416226.html
评论列表(0条)