I have a list of a class created in c# that I have to send its values to a javascript file. I have created a string in c# and put the values of the list in it:
count = 0;
JString = "[";
for(i=0; i<x; i++)
{
JString += "{Source:" + A[i] + ", Number:" + 3 + ", Target:" + B[i] + "},";
count++;
}
JString = JString.Remove(JString.Length - 1, 1); //to remove the last ,
JString += "]";
GraphData.Text = "" + "var JString =" + JString + " ;" + "var count =" + count + " ;";
GraphData is a label to save the string.
In the JavaScript file, I added:
$("#GraphData").val(); //to get the string sent
But it's not working this way. Am I doing something wrong?
Thanks in advance:)
GraphDatawhen it's rendered on your browser? I think anasp:Labelgets rendered as a<span>, in which case you'd want to call$('#GraphData').text()to get the inner textiwon't be able to ever catch up.