What's preferred for this - master page or page inheritance?
I have a need to create a page to edit an entity in my system and a page to view an entity. The difference between the pages is the menu bar and a few other controls.
I currently have two 开发者_JAVA百科options:
- Create a master page with a few content placeholders and fill them up in the edit and view pages.
- Create a base page for them and inherit from it.
Which option do you recommend?
Master pages let you inherit both code and markup.
A base page (really a base class that inherits from Page) only lets you inherit code; any associated markup will have to be injected, which is a good thing to avoid. Trying to do some partial class thing with a Page that has markup is never a sound approach from an architectural perspective, even if you can make it work.
Since your pages seem to share markup, that means a Master page would be the better answer.
BTW, don't forget that you can nest Master pages, so if you need several on your site, you can layer them. You can also access methods and properties in the Master page from the child pages, if needed.
Since there are differences in the interface and not only in the behavior, I'd recommend using master pages
精彩评论