Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass array from Asp.net 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

like image 815
Julius A Avatar asked Dec 01 '08 15:12

Julius A


1 Answers

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.

like image 118
Joel Coehoorn Avatar answered Sep 19 '22 02:09

Joel Coehoorn