Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Creating Usable Page Templates in ASP.NET : Page 7

Overcome ASP.NET's lack of page templating using this robust and upgradeable templating approach.


advertisement
Migrating to ASP.NET 2.0
In October 2003, Microsoft officially outlined the specifications for ASP.NET 2.0, code-named "Whidbey". One key feature is Master Pages, Microsoft's better-late-than-never implementation of page templates. A master page is a new type of control, a sibling of the current Page and UserControl classes. In it, you define your page template. Then, you create content pages which reference one of the master pages contained within your application. Master Pages are seamlessly integrated with the ASP.NET framework, and integrate well into the designer. When you're designing a content page, the UI from the master page displays semi-transparently in the designer so you can see the completed design without having to run the application.

Work you perform to implement template pages today isn't wasted—you can migrate the model described in this article to the new Master Pages architecture when ASP.NET 2.0 becomes available. Table 1 shows the functional equivalent for each aspect of this architecture. When you migrate to ASP.NET 2.0, you'll need to convert your page template user controls into master pages. For multiple page templates, you can create a base implementation from the MasterPage class. Then, you can define all the customizable properties. One drawback is that you can't set these properties declaratively, because you access the master page through the Content control. Instead, you will have to set these properties in the code-behind file using the Page.Master property.

Templating Model ASP.NET 2.0
PageBody control Content control
NamingPlaceHolder control ContentPlaceHolder control
PageTemplate User Control Master Page
Customizable properties defined in PageBody class Customizable properties defined in MasterPage code-behind class

Author's Note: When this article was written, it was too early to determine exactly how Microsoft will implement Master Pages in ASP.NET 2.0. Therefore, the information presented here is subject to change and should be treated lightly.

Developing an efficient page templating scheme is far from straightforward. But with some knowledge of how server controls work you can construct a scalable scheme for any Web application. Furthermore, this model can be extended to accommodate multiple-page templates within a single site. You can incorporate this page templating scheme into your ASP.NET applications without writing much code.


Joe Agster is a .NET software developer for a major company in Las Vegas. He also works as a software consultant and developer specializing in the .NET Framework. He can be found on the Web at www.geekyfrog.com, or reached by email .
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date