I have this following structure:
public class Dummy
{
public string Name { get; set; }
public InnerDummy Dum { get; set; }
}
public class InnerDummy
{
public string Name { get; set; }
}
And an ActionResult that receives a Dummy
[HttpPost]
public ActionResult Index(Dummy dum)
{
var dsad = dum;
//var dwss = idum;
return RedirectToAction("index");
}
On my view I have:
@model TestMVC3Razor.Controllers.HomeController.Dummy
@using (Html.BeginForm())
{
@Html.TextBoxFor(o => o.Name)
@Html.EditorFor(o => o.Dum)
<br />
<br />
<input type="submit" />
}
It is posting
Name=xxx
Dum.Name=yyy
But when I try to get dum.Dum.Name on the ActionResult I get null instead of yyy. Is this a bug or just the way it is? Am I not using it right? Do I need to implement a new binder for this?
HI~ your view should use
@Html.EditorFor(o => o.Dum.Name)not
@Html.EditorFor(o => o.Dum)And postback Controller:
If you have problems about it, please let me know 🙂