I have a view with @model declared as type FullModel;
public class FullModel
{
public IList<Record> SomeRecords {get;set;}
public Record NewRecord {get;set;}
}
This view displays SomeRecords and also displays the form for publishing the NewRecord method to the controller, defined as:
public ActionResult CreateNew(Record record)
{
...
}
Something like that:
@using (@Html.BeginForm("CreateNew", "RecordController"))
{
@Html.TextBoxFor(x => x.NewRecord.SomeProp)
...
}
But this does not work, because the path starts with root FullModel, so the POST data becomes NewRecord.SomeProp, and the controller expects Recordas root, the path should beSomeProp
What is the usual \ right way to handle this?
source
share