I am new to MVC, and have a MVC 4 web application and I retrieve a collection of items in the application start(static reference data). I want to display this collection of items when my view loads and loop through it creating links on view, I want to use javascript to inject this information. I found a post where they mention doing it in the view like this
<script type="text/javascript>
<%= Model.JavascriptToInsert %>
</script>
but I am looking for a working example of implementing this approach. Any guidance would be appreciated.
You should serialize your collection to json before you put it to your page.
Use ViewBag to show the data
Controller:
View:
Use strongly-typed view
Controller:
View: