Rick van den Bosch - Blog

... on .NET, software architecture, software development and whatnot

Recent Posts

Tags

News

  • Live space

    Photo blog

    Follow me at twitter

    Rick  van den Bosch

    LinkedIn profile

    Add to Technorati Favorites

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Community

Email Notifications

Blogs I read

Interesting links

Archives

October 2007 - Posts

HowTo: Set the Theme for a MasterPage (from code)

The MasterPage doesn't have a property for setting the Theme at design time. Despite this, I wanted to set the Theme for a MasterPage, so I decided to set it from code. I was aware of the possibility to set the Theme through the web.config, but that wasn't the way I wanted to set it. One of the reasons being it would result in the theme being applied to the entire website.

I tried to use the Page_Load, but that resulted in the error "The 'Theme' property can only be set in or before the 'Page_PreInit' event.". That sounds logical, because the Theme makes the Page render in a specific way. So I added a Page_PreInit method with the right parameters, but that didn't do anything. As it turns out, the Master Page doesn't have a Page_PreInit...

To be able to set the Theme for a MasterPage from code, follow these steps:

  1. Add a class with the name ThemeModule (or any other name)
  2. Let the class inherit from IHttpModule
  3. Implement the init method as follows:

    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += HandlePreRequest;
    } 
  4. void HandlePreRequest (object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;
        if (page != null)
        {
            page.PreInit += delegate
                                {
                                    page.Theme = DetermineTheme();
                                };
        }
    }

  5. Add the HttpModule to your web application through the web.config:

     
    <
    httpModules>
        <add name="ThemeModule" type="Howtos.ThemeModule"/>
      </httpModules>

That's it! Hope this helps.


A week ago I came up with this solution together with a good friend of mine. The code was on his machine, so he said I had to add a 'thanks to' in this post. Well, here it is: thanks 2 Sander van Kemenade! ;)

DreamScene is here! But what happened to the other Windows Vista Ultimate Extras?

Back in July, Barry Goffe (Director Windows Vista Ultimate) mentioned that the missing Extras identified in January would be released at the end of the summer. I just got a bit curious about when these Extras would finally be released, so I visited windowsultimate.com again. And there it was: DreamScene was released recently (September 25th). And although I'm not quite sure if I'll use this ever day, it's kind of a cool feature. Isn't it?

On the other hand: I'm still waiting for more Ultimate Extras. The ones Barry Goffe talks about are only Windows DreamScene and the remaining 20 Language Packs. But Microsoft made us believe there would be so many more. I can imagine the extras were a reason for a people to choose Ultimate. Let's see if Microsoft will "ship a collection of additional Windows Ultimate Extras over the next couple years that we are confident will delight our passionate Windows Vista Ultimate customers". According to the blogpost, "once we ship Windows DreamScene and the remaining Language Packs, we will provide more information about the next Extras". We'll see.

HALO 3: my (first) 2 cents

WOW
The single player mode feels like a multiplayer game, with excellent gameplay. Certain parts of the game are pretty creepy, and I like it that there are some surprising elements in there. Sometimes you expect something to happen, which doesn't. And when you least expect it.... So the (story in the) game is original. That makes a game interesting to play. One of the things I like a lot is that you can use almost everything your opponents use, like vehicles and weapons
The multiplayer part is just great. I played online with some friends this weekend, and we had a blast!

Me like ... !


By the way: I somehow lost my saved game. I already reached the sixth level, but when I started playing yesterday, the only option I had was 'Start solo game' in stead of 'Continue solo game'. I'm in level three again, but that kinda sucks. Maybe it has something to do with my Xbox freezing up when I used it as a media center extender. On the other hand, that might be odd, because Halo wasn't even running at that point.