Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 24, 2007 03:05 PM by tgmdbm
Dec 24, 2007 06:13 AM|LINK
There is some data I would like to retrieve from the model and display on the master page. Right now, I am using the hack of having the master page access the model directly but that doesn't seem to fit with the seperation of layers design methodology of
So besides making a procedure that gets called with every controller action, how would I go about making a universal bit of code that runs with the controllers to retrieve the data from the model.
Thanks in advance. :)
Dec 24, 2007 03:05 PM|LINK
create a base class for your controllers which extends System.Web.Mvc.Controller
override the RednerView(ViewContext) method and add your data to viewContext.ViewData.
If you're using strongly typed viewdata then you'll probably what to write a base class for all your view data types which contains the data for your master page.
However, there's a bug with the way the ViewMasterPage<T> works regarding the type of the generic parameter.
Check out the following post for a nice solution http://forums.asp.net/t/1195178.aspx