Suppose I have several models as follows:
public class Model1
{
public int ID{get;set;}
public string Name{get;set;}
}
public class Model2
{
public int ID{get;set;}
public string Name{get;set;}
}
class CommonViewModel
{
public string Title{get;set;}
public Model1 model1;
public Model2 model2;
}
and I have a razor view as follows
@model ProjectName.CommonViewModel
@Html.LabelFor(m => model.Title)
@Html.EditorFor(m => model.Title)
@Html.LabelFor(m => model.model1.Name)
@Html.EditorFor(m => model.model1.Name)
on my controller, I have a message that takes a CommonViewModel as a parameter. The general presentation model will matter for Title, but not for model1.Name. Why and how can I get this value, stored and sent back to the post, back to the controller.
source
share