I want to accept List as argument of javascript function.
I am calling this function from code behind.
And passing one List to the function.
But i got "System.Collections.Generic.List`1[System.Int32]" as value of argument when function called.
What should i do to get list when function called.
My code is:
Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
List<int> num = new List<int> { 12, 13, 14, 15, 16, 17, 18 };
List<int> oddNum = num.Where(n => n % 2 == 1).ToList();
ScriptManager.RegisterStartupScript(this, GetType(), "test", "test('"+oddNum+"');", true);
}
Default.aspx
<head runat="server">
<title></title>
<script type="text/javascript">
function test(oddNum) {
alert(oddNum);
}
</script>
</head>