I am passing a C# string array into a method that is using TagBuilder to build some Javascript. I don't seem to be able to get at the actual items within the array in my Javascript :
public static IHtmlString NewsTicker(this HtmlHelper htmlHelper, string[] arrTickerContents)
{
TagBuilder script = new TagBuilder("script");
script.Attributes.Add("type", "text/javascript");
script.InnerHtml = @"
var rss_scr_contents = new Array();
$.each('" + arrTickerContents + @"', function (i, objValue) {
rss_scr_contents[i] = objValue;
});
return MvcHtmlString.Create(script.ToString());
}
This results in the following source code :
var rss_scr_contents = new Array();
$.each('System.String[]', function (i, objValue) {
rss_scr_contents[i] = objValue;
});
What is the correct syntax to do this?