I am trying to figure out how to assign an array in my C# code behind and call a JavaScript function that uses that array. The JavaScript function looks like this:
<script type="text/javascript">
var TotalData = new Array();
function Show()
{
TotalData[0] = "Jan, 25";
TotalData[1] = "Feb, 42";
alert("hai");
}
In the Page_Load method of my C# code behind, I want to assign the same array and then call the Show() JavaScript function. How can I achieve this?
protected void Page_Load(object sender, EventArgs e)
{
//string[,] TotalData = new string[2, 2] { { "Jan", "25" }, { "Feb", "42" } };
//string serializedNumbers = (new JavaScriptSerializer()).Serialize(TotalData);
//need to assign TotalData array here.instead in javascript.
ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:Show(); ", true);
}