Click here to Skip to main content
15,897,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have my code behind
XML
SiteServices siteServiceobj = new SiteServices();
            List<Site> siteList = siteServiceobj.GetAllSites(2);
            List<string> latLongList = (from site in siteList select "'" + site.NominalLat.ToString() + "," + site.NominalLong.ToString() + "'").ToList<string>();
            var geocodevalues = string.Join(",", latLongList.ToArray());
            List<string> OmessageList = (from site in siteList select "'<span class=formatText >" + site.SiteName + "!!!</span>'").ToList<string>();
            String message = string.Join(",", OmessageList.ToArray());

            ClientScript.RegisterArrayDeclaration("locationList", geocodevalues);

            ClientScript.RegisterArrayDeclaration("message", message);

and from front end
i am using following script
XML
<script type="text/javascript">
       function alertfunction() {

           alert(locationList);
           alert(message);


       }
       window.onload = alertfunction;
    </script>



but it is showing loca
tionList
is undefined
can anyone help me out here
Posted

1 solution

The variables may not be completely downloaded before the onload event is fired.

Try using RegisterStartupScript with the alertFunction rather than window.onload
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900