How to pass array from server side to Javascript function on client side

How do I pass an array I have created on the server side onto the client side for manipulation by Javascript?

Any pseudo code will help


You'll need to embed it as a javascript array declaration into the page. There are a number of ways to do this, but it generally means turning the array into text that you write to the page, probably using the ClientScriptManager.

I'm hoping for better javascript integration in a upcoming verison of ASP.Net. Moving the value of a server variable —any server variable— to the client ought to be supported with a simple, one-line function call. Not the back-flips we need right now.

Another way would be to use the RegisterArrayDeclaration method of the Page object (deprecated) or in the ClientScriptManager class. See MSDN for details.

Need Your Help

In Ruby, via Sinatra, how do I get a link within an `li` tag?

ruby sinatra

I am using erb and ideally, I would like my html to look like this:

ASP.NET: Web Service or WCF for simple ajax call?

c# wcf web-services

I just want to simply call a method on my web service via ajax and have it return a value.