Search code examples
asp.net-mvcviewbag

ViewBag in JQuery


I am using ViewBag value as follows :

var date = "@ViewBag.fromDateForEditMode"
$('#FromDate').val(date);  

All I am getting is @ViewBag.fromDateForEditMode and no value.


Solution

  • The Razor engine doesn't execute when MVC is rendering an HTML file, so nothing will parse @ViewBag.fromDateForEditMode and replace it with the ViewBag property value :)