我的Model C#中有一个List<string>
,在我的Views中被称为@Model.Names
。从List中填充JS Array <string> C#
填补这一名单我想从该列表中的数值填写的javascript数组,为了做到以下后:
var myArray = [];
//fill myArray with values from @Model.Names
$("#tags").autocomplete({
source: myArray
});
所以当<input id="tags">
用户类型,他将得到一个自动完成在运行时填写的名称列表。
任何想法该怎么做?
看看这个帖子:http://stackoverflow.com/questions/18470702/how-do-i-convert-a-c-sharp-liststring-to-a-javascript-array – andreasnico