I am trying to iterate the contents of a string array, that was put in the ViewBag by the controller, in javascript.
In the controller:
ViewBag.Addresses = new string[] {"a", "b", "c"};
And in the view:
<script language="javascript" type="text/javascript">
function ExecuteOnLoad() {
var array = How do I get "a", "b" and "c" here?;
for (var i = 0; i < array.length; i++) {
doSomething(array[i]);
}
}
</script>
I searched a lot for an answer but seem to find solutions only for the razor view engine. What about web forms?