You must Sign In to post a response.
  • Category: ASP.NET

    Pass decimal array from code behind function to javascript function

    How do i pass decimal array from code behind function to javascript function, please let me ASAP.
  • #765323
    You can use ClientScript.RegisterStartUpScript to inject javascript into the page on Page_Load, see below snippet
    List<string> tempString = new List<string>();
    tempString.Add("Hello");
    tempString.Add("World");
    StringBuilder sb = new StringBuilder();
    sb.Append("<script>");
    sb.Append("var testArray = new Array;");
    foreach(string str in tempString)
    {
    sb.Append("testArray.push('" + str + "');");
    }
    sb.Append("</script>");
    ClientScript.RegisterStartupScript(this.GetType(), "TestArrayScript", sb.ToString());

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


Sign In to post your comments