Well, my ASP.NET 2.0 content management system seems to be working well, and I've already converted three of my managed sites to use it. I've found a few things that might be helpful if you're doing similar work with dynamically assigned master pages.
To start with, assigning the master page to a page is pretty easy. It's done in the OnPreInit event handler, as shown here:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
base.MasterPageFile = somefilename;
}
I have this in a BasePage class that all my web pages inherit from. This saves me from having to duplicate the code everywhere.
Another thing I do in the BasePage is set the page title. However, there's a trick to this, depending on what event you do it in. Each of the pages for the CMS are assigned to a template to display them. Each template inherits from BasePage, which takes care of assigning the master page to it. In the OnLoad event of the template page, I set the Title property of the page. However, I want each page's title to be prefixed with something else.
The OnLoad event of the BasePage class takes the Title set by the child page and uses a format string to assign it to the page. If you get the events out of order, the BasePage doesn't effectively set the page title. In my example, the OnLoad of the child page sets just the 'subtitle', and the OnLoad event of the BasePage uses that Title and prepends it. That seems to work well.
One other recommendation when working with dynamic master pages: have a default master page. When you're editing your ASPX pages, you can use the asp:Content tag only if a master page is set in the @Page directive. Since I'm dynamically assigning the master page, I had been leaving out the MasterPageFile directive. The result of this is that the site won't build properly when you choose to Publish the site. My solution is to pick one of the MasterPageFiles for each template page and then remove it when I put the template on the host server. You can probably leave it in with no problem since it's being replaced, but I'm still experimenting with that.
I'm definitely sold on master pages and I'm in the process of converting all my 1.1 sites to that format. It's much less of a hack than all the other options I've implemented for 1.1 sites to provide a common look-and-feel. Microsoft definitely learned from their oversight in 1.0/1.1 with this feature.