Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  27] [ 1]  / answers: 1 / hits: 17990  / 13 Years ago, tue, april 19, 2011, 12:00:00

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?


More From » asp.net

 Answers
25

There 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


[#92658] Sunday, April 17, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joanneamiyaa

Total Points: 532
Total Questions: 127
Total Answers: 98

Location: Guam
Member since Tue, Nov 3, 2020
4 Years ago
;