ASP MVC html helpers in partial views

Posted by Rabbi on Stack Overflow See other posts from Stack Overflow or by Rabbi
Published on 2011-01-11T02:04:16Z Indexed on 2011/01/11 2:53 UTC
Read the original article Hit count: 178

Filed under:

I am still trying to figure out how to create reusable partial views in MVC

Lets say I would like to create a partial view to display a form for submitting an address. Then in my ViewModel I have two addresses (Home address & Work Address) So I would think that in my view I call HTML.Partial for each one like this

@Html.Partial("Address", Model.HomeAddress)
@Html.Partial("Address", Model.WorkAddress)

but what happens is instead of the fields having names like HomeAddress.Street, HomeAddress.City etc. they just have the regular field names Street, City, etc. so the binder on the HTTPPost action has no idea what to do with them

Thanks in advance

© Stack Overflow or respective owner

Related posts about asp.net-mvc