In my HomeController
, I defined:
static void send_data_to_log(ref DateTime last_time)
{
// do something
}
in my index of the controller, I defined:
DateTime last_time = DateTime.Now;
ViewBag.my_last_time = last_time;
send_data_to_log(ref last_time);
now I want to use this function and this variable(last_time) in my index.cshtml file.
I tried:
<input type="hidden" name="" id="my_last_time" value="@ViewBag.my_last_time" />
@send_data_to_log(ViewBag.my_last_time);
but I got error :/
I want that the viewbag.my_last_time and the last_time will be updated in the function.
any help appreciated!