Templating ASP Pages using a Base Class

Robby

Ultimate Contributor
Joined
Nov 17, 2002
Messages
3,460
Location
Montreal, Ca.
This download illustrates how to create a base class from which all your aspx pages can inherit.

Why use templates?
If you’re designing a web site with more than a couple of pages then templates could be the answer. The benefits of well designed templates; getting rid of redundant code, easier to separate HTML from server-side scripts as well as the obvious, consistent look and reuse of UI code.

Why not use User Controls?
User Controls have their place as well. If anything they can be even easier to create than templates. Perhaps I’ll visit this topic at a later date.
Actually, I whipped up this sample because recently many were asking on how to use Includes in ASP.NET. So I figured why use Includes when you can be using Templates and User Controls.

Most of the code in the sample project is commented otherwise it should be self-explanatory.
 

Attachments

Back
Top