ASP.NET MVC 3 - Best ViewModel Practice

I have a Razor view with a lot of graphs and other text fields that receive data from the controller. I am going to transfer ViewModelfrom the controller to a view, which will then analyze the relevant content and display it.

Can anyone suggest if the above approach is best practice for solving such problems in MVC?

A class ViewModelmay look like this:

public class ViewModelDemo
{
    public MyChart chart {get;set;}
    public string LeftContent {get;set}
    public string bottomContent {get;set;}
    public ChartLeged legent {get;set} 
    ......
}

public class MyChart
{
   public List<int> xAxis {get;set}
   public List<int> yAxis {get;set;}
   ......
}

The reason I'm trying to return ViewModelis because there may be parts of the page that have different data.

+5
source share
2 answers

. ViewModel - . . 12.1.5 MVC ( )

- . , . , , , . , . . , , .

http://www.manning.com/palermo/Samplechapter12.pdf

+3

, - .

, , . , , ecc.

+2

All Articles