I created a partial view that I would like to use for reuse on different pages of my site.
Currently, for each web page, I am creating a ViewModel that matches all the information I would like to show, and then sending it to a view that is compromised from 3 separate partial views. Here is a simplified example:
public ActionResult Index()
{
MyViewModel m = new MyViewModel();
MyViewModel modelData = m.GetModelData();
return View(modelData);
}
public MyViewModel GetModelData()
{
ModelData modelData = new ModelData();
modelData.employees = GetEmployees();
modelData.products = GetProducts();
modelData.prices = GetPrices();
return modelData
}
On my web page, every partial view inherits from the same presentation model, which allows me to strongly print each partial view:
Inherits="System.Web.Mvc.ViewUserControl<DomainModel.Entities.MyViewModel>
, ( " .ascx" ) -, . , DomainModel.Entities.MyViewModel, , , . CheckOutViewModel.
, ? asp.net mvc 2, - ?
- , - ...