I have following code and the problem is that values I am sending from the form are stored in additional class in model and after submit the values are NULL in controller model.
Controller:
public ActionResult Territory(TerritoryVM m)
{
if (ModelState.IsValid)
{
!!! m.TerritoryFormItem IS NULL !!!
}
}
Model:
public class TerritoryVM
{
public TerritoryVM()
{
}
public TerritoryFormItem TerritoryFormItem;
}
Class used in model:
public class TerritoryFormItem
{
[Required, DisplayName("Territory Name")]
public string Name { get; set; }
}
View:
@Html.LabelFor(m => m.TerritoryFormItem.Name)
@Html.TextBoxFor(m => m.TerritoryFormItem.Name, new { @class = "form-control" })
Any Idea ?