Build Logo Single Page Web Sites

The Build Team - Specializing in "Proof of Concept" applications
Alliance Logo
Home
   Single Intro
   Includes
   Server Execute
   inc_clientNav
   Demo

Using query strings to separate navigation from content

I originally developed this technique to create a site that would have all the benefits of a framed page without all it's drawbacks. It turned out to be a great way to build and maintain a web site. Since all the navigation is on one page, one only has to scroll up or down to see what's going on. No more bouncing from file to file to file to see what's happening.

We all know that we can use .css files to separate formatting from content. But how do we easily separate navigation from content?  The technique illustrated in this article uses query strings to control  the pages to be displayed. If your server supports it, the server.execute version should be used.

The entire site is on the index.asp page. index.asp acts like a traffic light, directing what will be displayed and where. 

<a href= index. asp? nav= main& page= main>Home </a><br>
<a href= index. asp? nav= client& page= clientMain> Client Main</a> <br>
<a href= index. asp? nav= client& page= clientPageOne>Page One</a> <br>
<a href= index. asp? nav= client& page= clientPageTwo>Page Two</a> <br><br>

Then depending on the query string values, the appropriate page will be displayed in the proper cell to the table layout.

strNav = request("nav")

Using include files:

<try><td width= "150">

<% ' Here we decide which left navigation menu to display

Select Case strNav
        Case "", "main"    ' Default %>
          <!--#include file="inc_mainNav.asp" -->
  <% Case "client" %>
          <!--#include file="inc_clientNav.asp" -->
  <% Case "sales" %>
          <!--#include file="inc_salesNav.asp" -->
  <% Case Else %>
          <!--#include file="Error.asp" -->
  <%
End Select %>

</td><td>

Using server.execute:

<try><td width= "150" >

<%
' Here we decide which left navigation menu to display

Select Case strNav
   Case "", "main" ' Default
      Server.Execute("inc_mainNav.asp")
   Case "client"
      Server.Execute("inc_clientNav.asp")
   Case "sales"
      Server.Execute("inc_salesNav.asp")
   Case Else
      Server.Execute("Error.asp")
End Select
%>

</td><td>

The query strings used in this example come from the menu pages - inc_mainNav.asp,  inc_clientNav, inc_salesNav, which are in the usual left cell of the page layout table. But the query strings can come from anywhere. At look at the index.asp (includes version) or index.asp (server.execute version) and  inc_clientNav code may clarify things a bit.

Try the Demo
Down load the Demo - 
   Includes version:  SinglePage.zip 
   Server.Execute version:  SinglePageEx.zip
See this technique in action on a production site. Note that the entire site is on one page:
    TechEd Long Beach

Tips:

  • Since the entire site is on one page,  you only want to use the code that would be between <body> and </body>  tags when you use your page as an include file.
  • Use a well thought out naming convention to keep related files grouped. This way you'll avoid the necessity of using folders to organize the site.

Please continue to the related article, Rapid Application Development, where we'll be calling subs instead of include files. Very useful when developing a database intensive application.

Special Thanks to:
  Brian Bilbro
  Phillip Quinn
  David Penton
  G. Andrew Duthie

Note: It has been pointed out that the technique/method I've written about in this article is remarkably similar to Fusebox and seems to be used at the IBuySpy Portal site. Let it be known that the technique explored in this article I developed independently.

Other articles:

Michael Brinkley - Janurary 2, 2002
Send comments to: Mbrink1111@yahoo.com