donderdag, februari 08, 2007

 

ASP.NET: Master Pages

Master pages are a way in ASP.NET 2.0 to have a common design, header and footer for all your pages. It is a nice concept, and very popular amongst 'newbies' such as myself it would seem. Anyway, I created a master page for about2findout.com. The basics on master pages can be seen in this excellent video tutorial.

My master page has methods to visualise the five categories of pages: findout (pink), explain (green), helping hand (yellow) and community (blue). It also has a method to display a warning, informational, error, security or confirmation message. At the bottom of the master page is a section to add comment such as bugs or suggestions to any page. This will be used to capture feedback during the beta testing phase.





Q: How can you access the methods and properties of the master page?
A: If you want the Master property to be available, with IntelliSense, just add a < @MasterType VirtualPath= &gt statement to the .aspx page. Once that is done, use the Master object as you would use any other object.

Q: Can master pages work with AJAX?
A: Sure. Just remember you should have only one ScriptManager object per page. In my case I also needed Ajax on the master page, so that is where I included it. The alternative approach is to have a ScriptManager control on every derived page, but not on the master itself.

Q: How about master pages and translation/localisation?
A: To override the locale (language) settings you should normally override the InitialiseCulture() event of the page. This will not work for a master page as this is technically not a page but a user control. So you need to override the method on the 'real' pages, not on the master. Of course, that is a lot of duplication. So I made a base class that all my pages inherit from.

Labels:


Comments: Een reactie plaatsen

Links to this post:

Een koppeling maken



<< Home