I am very new to MVC 3 so this could be an easy one. I have a viewmodel with a nested object like this:
public class EventViewModel
{
public Event Event { get; set; }
}
public class Event
{
[Required]
public int Id { get; set; }
public string Title { get; set; }
}
In my 'create' view I do something like this:
@model EventViewModel
@Html.EditorFor(model => model.Event.Title)
Here's the code form my event controller:
public class EventController : Controller
{
[HttpPost]
public ActionResult Create(EventViewModel @event)
{
...
}
}
This editor is inside of form tag. When i postback to my controller the title of the event is null instead of what i entered in the form. Do I need some kind of custom binder? Am I doing something unconventional when I use nested objects in my viewmodel?