Writing javascript arrays from asp.net query results

liunx

Guest
Hi everybody, it's Doctor Nick :D

I am trying to create some dynamic select boxes which change depending on the choice made in another fixed select.
I am using javascript to avoid postback - and for the "backoffice" stuff I'm using asp.net.

I want to make 8 queries from my database in asp.net and write the results of these queries into my javascript (upon pageload) so that I can use them directly in the javascript.

Any ideas how to do that?Response.Write them to the page inside of script tags. You try that?That works well. Thanks :D

However I am having problems with some of the content in my database that messes up the javascript (the ' sign).
I am using .ToString in Asp.net in my datareader to get the values - is there any way that I can make the markup of the database content so "hard" that it will always only be interpreted as text in my javascript?By using the Replace() function I got it to work :D
 
Back
Top