Pass Session or Viewbag values to JS Files : ASP.NET MVC 3

added by urenjoy
5/17/2012 8:56:50 AM

2 Kicks, 687 Views

This post explains different ways to get Session, ViewBag or server side variable’s values in your external JS files.


5/17/2012 8:57:38 AM
In other languages I tend to use either the first method of setting javascript variables via a template, or html data attributes. It's sometimes handy to throw a bunch of page related data on the body tag or other easy to locate places.