Click here to Skip to main content
15,888,157 members
Articles / Web Development / IIS
Article

Fake Frames

Rate me:
Please Sign up or sign in to vote.
4.75/5 (4 votes)
20 Jul 2000 102.1K   820   31   11
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:

Image 1

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect VisionOne AG
Switzerland Switzerland
XicoLoko is a brazilian developer based in Switzerland.

Comments and Discussions

 
GeneralFrames and IIS Pin
gabyo5-Nov-04 12:04
gabyo5-Nov-04 12:04 
GeneralUsing a variation on this can be a real improvement! Pin
Mike Whitenton2-Jul-01 16:19
Mike Whitenton2-Jul-01 16:19 
Sorry I don't have time to include examples but here goes...
If you happen to use FrontPage for quick layouts read this section if not just skip to the next section.

Try switching the extension of the included files to .inc and change the editor for the extension within FP to FP instead of notepad.exe. This eliminates FP from throwing in HTML, HEAD and BODY tags into your menu.asp (now menu.inc) files etc. This alone will eliminate a bunch of headaches. But then try this to go with it...

Next save your content area in the main layout page like default.asp as default.inc and replace the removed area with only a single line to include the default.inc file. (more to follow after the next step)
This doesn't help much until you change all of your sites .asp files the same way. They just have the include default.asp line only and the content area is saved as filename.inc.
Then here is the kicker. The content area of each page is simply an include file like... products.inc or help.inc and the default.asp page contains the following code... (the $ needs to be replaced by the % of course)

<$Select Case lcase(Request.ServerVariables("url"))
Case "/products.asp" $>

<$ Case "/help.asp" $>

<$ Case "/policies.asp" $>

<$ Case "/whatsnew.asp" $>

<$ Case Else $>

<$End Select$>

What does all this mean? When you click on a link to products.asp the products.asp loads default.asp as well as all the .inc files listed above. Since the URL requested was products.asp the Select Case only allows the code in products.inc is the portion to execute.
Well, you now can modify the content area of the site without risking a page layout glitch. This takes a further step to seperate page layout from content. Now you only need to modify the default.asp page to change the entire layout of every page on the site!

Additionally, since the default.asp file is cached in the servers memory, and no other .inc files need to be loaded from that point on for navigation, the site becomes extremely fast!
Hope this hasn't been too confusing and inspires some new ideas!
If someone has the time it would be nice if they would try this and post some example files & code here.
GeneralRe: Using a variation on this can be a real improvement! Pin
C. Augusto Proiete12-Jun-03 10:47
C. Augusto Proiete12-Jun-03 10:47 
GeneralRe: Using a variation on this can be a real improvement! Pin
Mike Whitenton12-Jun-03 12:02
Mike Whitenton12-Jun-03 12:02 
GeneralRe: Using a variation on this can be a real improvement! Pin
C. Augusto Proiete12-Jun-03 15:46
C. Augusto Proiete12-Jun-03 15:46 
GeneralRe: Using a variation on this can be a real improvement! Pin
Mike Whitenton12-Jun-03 12:22
Mike Whitenton12-Jun-03 12:22 
GeneralRe: Using a variation on this can be a real improvement! Pin
C. Augusto Proiete12-Jun-03 15:49
C. Augusto Proiete12-Jun-03 15:49 
Generalinclude file alt Pin
30-Jan-01 2:33
suss30-Jan-01 2:33 
QuestionASP or IIS thing? Pin
Terry Mulvany2-Nov-00 17:59
Terry Mulvany2-Nov-00 17:59 
AnswerRe: ASP or IIS thing? Pin
zeta2-Nov-00 19:15
zeta2-Nov-00 19:15 
GeneralI've always called this "Server-Side Framing" Pin
Uwe Keim21-Jul-00 20:08
sitebuilderUwe Keim21-Jul-00 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.