Suppose our class is Dog:
class Dog
{
public int Age { get; set; };
public string Name { get; set; };
}
The controller has this Action:
public ActionResult Action(Dog dog)
{
...
}
And the View is like this:
using (Html.BeginForm("Action"))
{
Dog dog = MySession.GetDogFromSession();
@Html.EditorFor(d => dog.Age);
@Html.EditorFor(d => dog.Name);
<input type="submit" value="Action" class="btn btn-default" />
}
The problem is that when the action is called, the Dog instance in the parameters doesn't have the specified Age and Name when the form is posted.
How do you send a Dog instance through this form?
UPDATE:
The view here written is a partial view, so the model is already defined elsewhere.