I’m creating an ASP.NET site where some pages need to have a div floated to the left with the site menu in and other pages don’t have the menu div and instead the content takes up the entire page width.
I’m planning to use master pages – I was wondering how best to achieve this – a few immediate thoughts spring to mind:
- Create 2 master pages, one with menu and one without. When creating content pages choose which master to inherit from. This is straightforward, but may require more rework if the site design changes
- Create a single master page with a content placeholder for the menu. On each page include a menu div only if it is needed (seems more messy this approach)
- Nested master pages?
It seems like this may be a common problem, so interested in how this is normally addressed. Note I am questioning the need for having pages without the menu – it would be simpler if all pages had exactly the same structure.
Nested master pages is probably the standard answer and should work well.
An alternative approach that occurs to me would be to put your menu in a panel control on the master page and expose a property that lets you toggle the visibility of the panel. I have not tried this yet, so I am not sure how practical it is, but it might be a fun concept to play with. If it works the way I expect this gives you a single master page that can be reconfigured by the content page.