There are many ways to get a consistent
design across your website (and this is discussed in another
article) and one of these ways is by using
page templates. Basically that means that you are inheriting from the Page
class and implementing your own style to it. This article will take a look at
how you can use page templates on your site.
The Page Class and Page Templates
Your page essentially inherits from a
code-behind class and that in-turn inherits from the Page class. The
Page class is your ASP.NET page and when compiled, it compiles your page
to an object of this class so it can run. The class contains all of the stuff
needed to get your page processed and displayed.
Where do page templates fit into all of this?
Page templates are more or less inserted between the code-behind layer and the
Page class layer. So going backwards -
- You page inherits from a code-behind class
- Which then inherits from your template
- Which then inherits from the Page
If you check out the documentation for the
members of the Page class, you will see numerous methods, properties
and events that you have used before (most noticeably the Load event).
When you inherit the Page class you essentially get to use the members
to create your template and then use that template as what your code-behind