You could either change your action to
public ActionResult Index(ViewModel model)
in which case the model.InputData would be populated or use Bind attribute
public ActionResult Index([Bind(Prefix="InputModel")] InputModel model)
Question
I have a ViewModel
which holds my InputModel
as a property.
I use HTML helpers like so: @Html.TextBoxFor(m => m.InputModel.UserId)
for example.
The problem is that this generates: <input name="InputModel.UserId" />
And the model-binder does not populate the properties in my HttpPost
method:
public ActionResult Index(InputModel model)
I see there is a generic version of HTML helpers, I was thinking maybe I can leverage that somehow, but I havn`t yet figured out how. Or maybe there is a completley different way around this, that I'm not seeing since I am new to MVC.
La solution
You could either change your action to
public ActionResult Index(ViewModel model)
in which case the model.InputData would be populated or use Bind attribute
public ActionResult Index([Bind(Prefix="InputModel")] InputModel model)