A Precarious Balance

Sean Winstead's web site & blog
Welcome to A Precarious Balance Sign in | Join | Help
in Search

A Precarious Balance

Sean Winstead's web site & blog

Community Server 2.0: How Master.ascx gets used

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:

Published Sunday, April 02, 2006 10:45 PM by Sean Winstead
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Community Server Daily News said:

I don't know how to report this incredible news, so I'll simply pass along the words of Scott Dockendorf,
June 2, 2006 3:15 PM
 

Community Server Daily News said:

I don't know how to report this incredible news, so I'll simply pass along the words of Scott Dockendorf,
June 2, 2006 3:19 PM
 

Community Server Daily News said:

I don't know how to report this incredible news, so I'll simply pass along the words of Scott Dockendorf,
June 2, 2006 3:23 PM
 

Community Server Daily News said:

CSBlogs.com &quot;Soft&quot; Launch, as announced by Telligent MVP Jayson Knight, where among other things, he
June 26, 2006 1:51 PM
 

Community Server Daily News said:

This is a compilation of all Forum FAQ content on communityserver.org to serve as a timestamp of where
July 24, 2006 5:42 PM
 

The Brown Report said:

I'm not about to explain the reasons why I think Community Server is a great app.&amp;nbsp; This isn't at...
August 9, 2006 11:57 PM
 

Jason P. Brown said:

[article transplanted from it&amp;#39;s original home on jasonpbrown.com ] I&amp;#39;m not about to explain the
August 14, 2006 11:33 AM
 

Jason said:

Is there a guide on how to change and manage themese in CS2?

thanks

http://gridview.org
August 23, 2006 11:00 AM
 

scott said:

I just spent about half an hour trying to figure out how Master.ascx is wired up!!! Thank you for explaining it for me, haha...  I thought I was crazy, because I knew from experimentation that Master.ascx is being loaded, but like you, I couldn't find the reference to it, heh.  
August 24, 2006 7:23 PM
 

Sean Winstead said:

Hi Jason,
I apologize for taking so long to respond to your question. When I started dealing with CS 2 skins, I found a lot of good information at <a href="http://soup.co.za">http://soup.co.za</a>.
September 1, 2006 10:57 PM
 

FAQs - Communityserver.Org said:

FAQ posts contain multiple subject items appropriate to this forum, and will evolve over time with new

January 9, 2007 10:39 PM
 

Community Server Bits said:

While talking about Sean, his RSS Feed kicked out a fresh 25 posts and I noticed a good one he wrote

March 12, 2007 11:04 AM
 

Community Server Bits said:

If you want to customize Community Server, you're going to want to know about the role of CS Master Pages.

March 12, 2007 11:17 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit