Friday, November 13, 2009 2:08 PM
If you have a generic ViewModel, such as ContosoViewModel<TModel>, you can share this with the master page, to an extent, by implementing an interface to the data your shared master might need. This will allow you to avoid using things like ViewDataDictionary for something like a 'Current Customer Id'.
so, here's a sample class signature for a generic view model:
public
class EmsViewModel<TModel> : IEmsViewModel
and here is a typical view's Inherits attribute:
Inherits
="System.Web.Mvc.ViewPage<EmsViewModel<Finding>>"
and lastly, here is the master page's Inherits attribute:
Inherits
="System.Web.Mvc.ViewMasterPage<IEmsViewModel>"