ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Convert Comma separated String to JavaScript String Array in C#<p>Hi <a class="username" rel="doctork11">doctork11</a>,</p> <p>Check with the below code.</p> <pre class="brush: csharp">[WebMethod] public List&lt;string&gt; GetMonths() { var Months = &#34;January,February,March,April,May,June,July,August,September,October,November,December&#34;; try { var dq1 = &#34;&#39;&#34;; var dq2 = &#34;&#39;&#34;; var fdq = dq1 + &#34;,&#34; + dq2; var s = Months; var replace = &#34;&#39;&#34; + s.Replace(&#34;,&#34;, fdq) + &#34;&#39;&#34;; var myArray = new List&lt;string&gt; { replace }; return myArray; } catch (Exception e) { //Response.Write(&#34;&lt;script&gt;alert(&#39;&#34; + Server.HtmlEncode(e.ToString()) + &#34;&#39;)&lt;/script&gt;&#34;); throw; } }</pre> <p>in Javascript replace with double quote.</p> <pre class="brush: js">var jsVarMonths = data.d[0].replace(/&#39;/g, &#39;&#34;&#39;);</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/164562/Convert-Comma-separated-String-to-JavaScript-String-Array-in-C/https://www.aspforums.net:443/Threads/164562/Convert-Comma-separated-String-to-JavaScript-String-Array-in-C/Mon, 24 Sep 2018 05:19:41 GMTConvert Comma separated String to JavaScript String Array in C#<p>Hello,</p> <p>Thank you for the code. I actually figured it out. I really just need to write out my problem, take a nap and look at it again.&nbsp;</p> <p>Here's what I did.</p> <pre class="brush: csharp">protected string[] MthArray { get; private set; }</pre> <p>&nbsp;</p> <pre class="brush: csharp">var gs = new GetSiteStatsMaster(); gs.GetData(id); MthArray = gs.MonthsCs.Split(&#34;,&#34;).ToCharArray();</pre> <p>Then from GetSiteStatsMaster()</p> <pre class="brush: csharp">var sdr = cmd.ExecuteReader(); while (sdr.Read()) { MonthsCs = sdr.GetString(0); ... etc... }</pre> <p>the GetSiteStatsMaster returns a comma seperated value in a string.</p> <p>I just put that string into a Char Array splitting on the comma.</p>https://www.aspforums.net:443/Threads/164562/Convert-Comma-separated-String-to-JavaScript-String-Array-in-C/https://www.aspforums.net:443/Threads/164562/Convert-Comma-separated-String-to-JavaScript-String-Array-in-C/Mon, 24 Sep 2018 11:45:56 GMT