[out of date post... this deals with MS Atlas CTP... which has been change drastically and is now MS Ajax Extensions]
I discovered how to do something today that I want to remember (as well as to share with the world). But before I do that I must say something… (I know it’s a repeat statement, but it’s still nice to say, and I started this post before I wrote my other one)
I love the Atlas UpdatePanel!!!!!
Ok, now that that’s off my chest. We can delve into the mysteries of easily working with sites that have mutliple Masterpages and Atlas. I’m currently working on a project where the application renders itself based on the url passed to it. If the URL is localhost then you get one skin if it’s SomeOtherSite.com you get an entirely different rednering of the site. I have a base page class that all other pages inherit from. This BasePage contains logic to automagically place the correct MasterPage (something I’m not going to go into here).
Each Masterpage has a ScriptManager component in it (yep, that means I’m shoveling the Atlas client down on every page which may be a bit inefficient, but it should get Cached when I’m running with debug=”false”.
I decided to not expose a ScriptManager property (and yes, you can always search for the control in the MasterPage from your individual page, but I wanted something a little more elegant). I decided to expose just the EnablePartialRendering property. So I added the following code to my BaseMasterPage (all my MasterPage CodeBehind’s inherit from this class):
private bool _AtlasPartialUpdates = false;
/// <summary>
/// Gets or sets a value indicating whether atlas uses partial updates or not.
/// </summary>
/// <value><c>true</c> if [atlas partial updates]; otherwise, <c>false</c>.</value>
public bool AtlasPartialUpdates
{
get { return _AtlasPartialUpdates; }
set { _AtlasPartialUpdates = value; }
}
[Yep, I use GhostDoc, too]. This let’s my pages access the Partial Updates. (BTW, I set the <% @MasterType %> on all my pages to this BaseMasterPage type, so I don’t need to cast the page’s Master property to this type).
Another thing I discovered is that You can’t change the setting of EnablePartialRendering beyond the PreInit event, so I have to make this decision early on… That’s actually easy… each page either uses Partial Rendering or it doesn’t. So in the PreInit event of each page that needs Partial Rendering (for UpdatePanels), I simply set this property to true via the page’s Master property. It looks like this:
protected override void Page_PreInit()
{
Master.AtlasPartialUpdates = true;
}
Since MasterPage PreInit happens after the Page PreInit I can do this in each master page-
protected void Page_PreInit(object sender, EventArgs e)
{
ScriptManager1.EnablePartialRendering = AtlasPartialUpdates;
}
Now I can use the UpdatePanel on any page I want. I also have enabled Atlas functionality on my entire site (I can just use controls… well, the UpdatePanel at least). That’s it (I hope this helps someone else)…
[tags: Atlas, Ajax, ASP.Net, MasterPages]
Print | posted on Friday, April 28, 2006 6:00 PM