I have a hidden field in my view like this:
using (Html.BeginForm("Action", "Schedule"))
{
@Html.Hidden("Id", Model.Schedule.Id)
...
}
And an action method that takes in the information like this:
public ActionResult AddEventToSchedule(Event NewEvent, Guid Id)
{
// Do something
}
I keep getting an empty Guid passed in, even when Model.Schedule.Id is not empty. I checked the html source and the hidden field is an empty Guid as well (used a breakpoint to verify that Model.Schedule.Id is not empty).
The strange thing is when I tried to access the Id value through the model like below, the html hidden field was populated correctly with the guid, but the model passed into the action method was empty.
public ActionResult AddEventToSchedule(Event NewEvent, ScheduleModel model)
{
// model.Schedule is null!
}