Answer the question
In order to leave comments, you need to log in
how to pass array from c# to javascript?
how to pass array from c# to javascript?
Answer the question
In order to leave comments, you need to log in
Judging by the tag, you want to do this in an ASP MVC application.
There is an option to do this on a view using Razor
<script>
var model = @Json.Serialize(Model.yourArray);
var model2 = @Html.Raw(JsonConvert.SerializeObject(Model.yourArray));
var model3 = [@Model.yourArray[0], @Model.yourArray[1], @Model.yourArray[2]]
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question