Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  154] [ 3]  / answers: 1 / hits: 68152  / 14 Years ago, sun, october 3, 2010, 12:00:00

I can pass a variable from MVC ASP.NET by using this :



var lastCategoryId = '<%=Model.CS.LastSelectedCategory %>';


This work fine with string or integer but how do I do with an array of strings? I have tried to pass the array the same way but the variable is set to System.String[] ?


More From » asp.net-mvc

 Answers
12

This should do



var someArray=[<%foreach (var s in myStringArray){%>'<%=s%>',<%}%>];

[#95428] Thursday, September 30, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
helenat

Total Points: 450
Total Questions: 95
Total Answers: 97

Location: Central African Republic
Member since Mon, Aug 10, 2020
4 Years ago
;