65.9K
CodeProject is changing. Read more.
Home

Fake Frames

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.75/5 (4 votes)

Jul 21, 2000

viewsIcon

103007

downloadIcon

820

An article about faking frames to have pages with the same layout by using server side includes

Introduction

So you want to have a page that has a menu in the left, your banner in the top and the copyright and contact info below. I call this the classic layout.

Usually you use frames to accomplish this wish. But if you don't want to use frames, you would have to copy the almost static parts of each section of the page to each page in your site. That's ok.

But if you have to update the menu or the contact email, you would have to change a lot of pages, which is a kind of boring :-/, and it would cost you a good amount of time.

The solution I have is to use server side includes for those parts that are static (menu, copyright info, banner, ...). With the use of tables you'll have a framework for your pages.

So to update one of this static items you change the include file and all the pages will be ok.

The example will have this look:

These are the include files:

  • left.asp : for the left menu
  • top.asp : for the banner image
  • bottom.asp: for the contact and copyright stuff

Using server side includes in ASP is easy: just create a page you wish to include (your menu, top banner, bottom copyright etc) and then in your main page add the declaration:

<!-- #include virtual="include_file.asp" -->

where include_file.asp is the file you wish to include. "#include virtual=" means the page's path is specified relative to the web root. You can also use "#include file=" which means the path is specified as relative to the current page's directory.

More information about include files can be found typing "#include" on the index page of MSDN.