Lewati array ke JavaScript dalam daftar inti bersih ASP
//Controller content
string[] array = {"Value1", "Value2", "Value3", "Value4"};
ViewData["Array"] = array;
//OR
List<string> array = new List<string>();
array.Add("value1");
ViewData["Array"] = array.ToArray();
//View content
<script>
$(document).ready(function () {
var array = @Html.Raw(Json.Serialize(ViewData["Array"]));
console.log("Array", erros.length);
$.each(array, function (key, value) {
console.log("Content", value);
});
});
</script>
NIP