What is the correct way to use partial view models in ASP.NET MVC2?

I'm new to MVC, but now I feel pretty comfortable with the template, especially finding ViewModels to be a great bridge between the controller and the view.

However, now I have to use Partial Views, and I'm a bit confused.

Demand

Well, in Wire Frames we have many different pages, but they have a common "grid".

The grid will be a partial view and will always display / consume / manipulate the same data type.

Questions

So, the main views, which include a partial view, will have different models ... since I can process models from a partial view.

If all models for views that use this particular partial view have a nested model for partial view as properties?

What is the best practice here?

cool greetings

+3
source share
1 answer

I find that when I build Partial, it helps a lot if I consider what Model will be for this Partial. I almost always find that if I think that reusing partial magnification is a lot.

A . Partial , , , " ", , , , , .

Partial, , , View , .

; , Partial, , View. / - , , .. ( Partials, , Ajax).

, MVC2 - ; Html.RenderAction() ( ) . , ... , "" ViewModel.

+2

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


All Articles