Santhosh Subramaniam

Santhosh Subramaniam

  • NA
  • 226
  • 102.9k

ViewBag not working in MVC

Nov 19 2014 4:12 AM
Hi Frnds,
   I am new to MVC application , in my application am using viewbag here is the code
 if ('@ViewBag.DTTime' != null && '@ViewBag.DTTime' != "") {
 $('#Containerdiv').val('@ViewBag.DTTime.ToString("yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture)');
 }

in Controller not assigning the viewbag DTTime, it is error.. 

this if statement always true  and the statement is executed,
how to stop,
Thanks in Advance. 

Answers (3)