Page Templates

  • Thread starter Thread starter Iyigun Cevik
  • Start date Start date
I

Iyigun Cevik

In my website, all of my pages have similar construction, for example
background color, header part, a menu, and a general table which all
contents're sitting in. I want to use these in several pages in my
application. For menu and header i can make server controls. But for
backgroud color of page and for a table covering all of the page i can't
make it.

The idea of making a template page and inheriting it in all pages appeared
in my mind, but i couldn't figured how i could do that. Because derived
pages override properties like Attributes and InnerHtml.
How can i make a template page and use it in all pages in my application?

I checked MSDN and web for some kind of template pages, but couldn't find a
solution.
Iyigun Cevik
 
Hi

I used <!--#include file="header.aspx"-->, the same for footer. I then
descended my .CS form class from a single class which enables / disables
menu items etc.


--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com
 
Iyigun Cevik said:
In my website, all of my pages have similar construction, for example
background color, header part, a menu, and a general table which all
contents're sitting in. I want to use these in several pages in my
application. For menu and header i can make server controls. But for
backgroud color of page and for a table covering all of the page i can't
make it.

The idea of making a template page and inheriting it in all pages appeared
in my mind, but i couldn't figured how i could do that. Because derived
pages override properties like Attributes and InnerHtml.
How can i make a template page and use it in all pages in my application?

I checked MSDN and web for some kind of template pages, but couldn't find a
solution.
Iyigun Cevik

Use the power!

You can simply make you outer template and build your content as User Web
Controls. As an example, let's say you have a simple site that would be
like:

About Page
Home Page
Whats New Page
Contact Me Page

On each page there is a left side navigation panel. At the top there is the
same header appearing on each page and at the bottom it is the same
copyright notice.

Normally in the old days I would build a single template and use an
"Include" to pull content into the single template. I have broke myself of
that bad habbit and now use web user control for each content page and build
one template and dynamically add the correct user control based on which
page they have selected. As an example of this you can see at:

www.GotTheAnswerToSpam.com

The page is built with a single template called Core.aspx. The main content
changes for each page based on the page they selected. I put the page in
the url so search engines can index each page. You could hide the parameter
in ViewState and force everyone to you home page regardless of which page
their were on when they saved your URL. You can see in the url that it
passes a "P=HowDoesItWork" for that page of content. The right side content
panel changes but the rest of the page stays the same. Really works slick
and if you use user controls for different purposes, you can take advantage
of the many forms of caches.

User Web Controls RULE! ;)
 
First thank you for your answer.
I was using same method in classical asp with server.execute. It's better
than putting include files on the top and bottom of every page. One of the
disadvantage of this system is about page links. Instead of names like
/About.aspx, having names like Default.aspx?Page=About is not so preferable.
Anyway, if I can't figure out a better way, i'll do in this way.
 
We've used the approach with user controls. We also changed global.asax,
adding code to the BeginRequest Event. In this code, we take a page request
like About.aspx and convert it to default.aspx?page=About. This way, our
links are to about.aspx. The only disadvantage of this method is that you
can't verify links with automated tools.

Jeff
 
Back
Top