Should an ASP.NET masterpage get its data from the view?

前端 未结 3 484
天涯浪人
天涯浪人 2021-01-13 22:01

I\'ve been playing around with ASP.NET MVC with a site containing a Master Page.

I created an MVC user control called ProductThumbnailControl. The user c

3条回答
  •  广开言路
    2021-01-13 22:53

    Our master page takes data from the view. We use strongly typed view names for our views and in the methods for that implementation we also add standard view data that every page needs from our persistent objects (like the application menu structure info, the user info to display on screen and so forth).

    This does have the disadvantage of making our view data for the master page not strongly typed like it is for the Model object, but it works very well for us.

    Your idea is also good. As the idea of the Master page is similar to the idea of inheritance, why not use inheritance to setup your model objects. You could take it a step further and create a model factory that produces your model objects and sets the base class data while it does so.

提交回复
热议问题