UPDATE: I've slightly changed this post to make it a bit clearer.
Community Server 2.0 (CS2) is architecturally rich. I've started a project where I need to teach a web designer how to create a theme for CS2. There's scant documentation so I've found myself digging through the code to figure it out.
CS2 makes use of master pages. It's not the master page functionality that is delivered with ASP.NET 2. Instead, it's a custom implementation from another company that allowed Telligent to use master pages before ASP.NET 2 was released.
From what I've read, master page Master.ascx is used throughout the website to control basic page layout. But I've not seen it explicitly referenced in any of the CS2 files. So a big question in my mind was "How in the world is Master.ascx even pulled into the website?".
Here's the answer. It's written here because I'll forget it in two days. It's also here for those of you interested in this kind of thing.
How CS2 invokes a master page
- The default Theme has a Masters directory containing all of the master pages. A master page is implemented via an ASCX file.
- Within the Masters directory, each CS2 module has its own master page. For example, the master page for the website root is HomeMaster.ascx. The master page for blogs is BlogMaster.ascx.
- A master page is pulled into the website via a CS:MPContainer element having a ThemeMasterFile attribute. If you look in {CS root}\WebDefault.aspx, you'll see a <CS:MPContainer> element with ID="Mpcontainer1" and ThemeMasterFile="HomeMaster.ascx". The ThemeMasterFile tells CS2 to look for the specified master file in the current theme's Masters subdirectory. In this case, default.aspx uses HomeMaster.ascx.
- There are other default.aspx files located in the CS website. For example, {CS root}\web\Files\Default.aspx. Its <CS:MPContainer> element references FileGalleryMaster.ascx.
At this point, you should see how a module's default.aspx file pulls in the module-specific master page. And you're saying "Sean, that doesn't tell me how Master.ascx gets used".
How CS2 happens to use Master.ascx
The key is in the implementation of the MPContainer element. If a page contains a <CS:MPContainer> element and that element does not have a ThemeMasterFile attribute then the master page for the element defaults to "Master.ascx".
As you saw, the default.aspx files have a ThemeMasterFile attribute on their <CS:MPContainer> elements. But here's another trick: The master pages referenced by the default.aspx pages also contain a <CS:MPContainer> element and that element does not have a ThemeMasterFile attribute.
To prove I'm not lying, look at HomeMaster.ascx. It has a <CS:MPContainer> element without a ThemeMasterFile attribute.
When a module-specific master page (e.g., HomeMaster) is "resolved", it ends up making use of a master page. So CS2 in effect has nested master pages. HomeMaster and the other module-specific master pages end up using Master.ascx by default.
I hope that makes sense. If not, please let me know.
--
Sean Winstead
Tags: CommunityServer