ASP MVC html helpers in partial view

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

Suppose 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 and work address), so I would think that, in my opinion, I call HTML.Partial for each such type

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

but what happens, instead of fields with names such as HomeAddress.Street, HomeAddress.City, etc., they just have the usual field names Street, City, etc., so the middleware in the HTTPPost action has no idea. what to do with their

Thanks in advance

+3
source share
1 answer

, . , , - . Brad Wilson : http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html

Partial EditorFor :

@Html.EditorFor(m => m.HomeAddress)

, , .

+3

Source: https://habr.com/ru/post/1784641/


All Articles