Model Binding and Field name prefixes in Views

May 12, 2009 at 1:59 PM
Edited May 12, 2009 at 2:01 PM

How does Model Binding work in combination with Field name prefixes in Views?

For example, here is my Edit Action in my Controller:

public ActionResult Edit(int id){
return View(GetItem(id));

And here is a Field in the Edit/Create View:

<%= Html.TextBox("myprefix.MyField") %>

This doesn't seem to work with field name prefixes; the input fields in the view aren't prepopulated with the values of the Model passed to the View. (If I remove the prefix, it works.)

The strange thing is that it works the other way around; when submitting my Create view to the Create controller, the binding works as expected.

How does this work? And why doesn't it work when passing a model to the Edit View?