Forcing EditorFor to prefix input items on view with Class Name?

Posted by Kohan on Stack Overflow See other posts from Stack Overflow or by Kohan
Published on 2011-01-05T16:43:26Z Indexed on 2011/01/05 16:53 UTC
Read the original article Hit count: 190

I have an EditorFor:

<%: Html.EditorFor(model => model.Client, "ClientTemplate", new { editing = false })%>

This will bind coming down to the view fine (as expected) but will not bind bind back when the model gets posted. This is due to the form id's not being prefixed with "Client."

Usually in this situation i just pass in model and then bind the inputs to model.Client.PropertyName in the Template but this is not an option in this case as the template is used on two different viewmodels (that have client on).

Any suggestions on getting this to bind properly?

Many thanks, Kohan.

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc