Currently, I am working on passing a predefined Type (List) to an asp.net web form that needs to be recognized by JavaScript when the page loads.
The sample data I am generating appears like this:
protected List<MapCoords> createCoordinateList()
{
List<MapCoords> latlng = new List<MapCoords>();
MapCoords m = new MapCoords();
m.xCoord = 34.241182;
m.yCoord = -77.946839;
latlng.Add(m);
m.xCoord = 34.242176;
m.yCoord = -77.94538;
latlng.Add(m);
return latlng
}
I am facing a challenge in figuring out how to make this list of coordinates accessible to JavaScript on the client side. Since the object has multiple properties (x, y), setting them to a hidden field is not feasible. I have previously used ajax calls to retrieve objects, but in this case, the mock data is generated through a server-side event, eliminating the need for ajax invocation. However, I want to avoid making a redundant call if possible.
My question is, how can I transfer this list of coordinates to JavaScript on the client side while maintaining the association between x and y properties, especially considering the potential addition of more properties in the future?
Cheers,