0

I have a function in JavaScript from this Google Chart

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Name',                                                                 'Manager', 'Tooltip'],
    ['Mike',                                                                 null,      'The President'],
    [{v: 'Jim', f: 'Jim<br/><font color="red"><i>Vice President<i></font>'}, 'Mike',    null],
    ['Alice',                                                                'Mike',    'wonderland'],
    ['Bob',                                                                  'Jim',     'Bob Sponge'],
    ['Carol',                                                                'Bob',     null]
  ]);

  // Create and draw the visualization.
  new google.visualization.OrgChart(document.getElementById('visualization')).
      draw(data, {allowHtml: true});
}

I don't understand how I can fill the data array variable, which is declared in JavaScript.

halfer
  • 19,824
  • 17
  • 99
  • 186
skhurams
  • 2,133
  • 7
  • 45
  • 82
  • This question is answered in [How do I give JavaScript variables data from ASP.NET variables?](http://stackoverflow.com/questions/553813/how-do-i-give-javascript-variables-data-from-asp-net-variables), [Passing variable from ASP.net to JavaScript](http://stackoverflow.com/questions/10540217/passing-variable-from-asp-net-to-javascript) and [Create javaScript variable in code behind of asp.net](http://stackoverflow.com/questions/4398338/create-javascript-variable-in-code-behind-of-asp-net) for example. Please show what you have tried. – CodeCaster Jul 11 '13 at 10:51
  • its not a simple variable its an array can you explain more – skhurams Jul 11 '13 at 11:02
  • 1
    i find a control http://googlechartnet.codeplex.com/wikipage?title=Samples&referringTitle=Home thanks anyway – skhurams Jul 11 '13 at 11:10

1 Answers1

0

You need to do something like following.

  string serverVariable = "abc";
        string script = string.Format("javascript:var j={0};", serverVariable);        
        ScriptManager.RegisterStartupScript(this, this.GetType(), "uniqueKey", script, true);
Jalpesh Vadgama
  • 13,653
  • 19
  • 72
  • 94