Any help much appreciated, not sure why this is not working, in my server side code i have:
foreach (var item in Model)
{
if (item.SiteLocation == null || item.SiteLocation.SiteLocationId == 0)
{ }
else
{
if ((item.SiteLocation.Latitude != 0) && (item.SiteLocation.Longitude != 0))
Page.ClientScript.RegisterArrayDeclaration("Sites", "'" + item.SiteId + "','" + item.SiteDescription + "','" + item.SiteLocation.Longitude + "','" + item.SiteLocation.Latitude + "'");
}
...........then i try to reference the array using the following code in Javascript :
for (var i = 0; i < Sites.length; i++) {
// Create and Element Object of type "option"
alert(Sites[i]);
}
..........but it says "Sites is undefined"
I've debugged server side and the "Page.ClientScript.RegisterArrayDeclaration" line runs a few times so no idea why object is not there when i use the Javascript, any ideas?