NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

A One Page Web Site

Written by Eric Smith, Northstar Computer Systems LLC

One of the goals in writing an ASP application is to minimize the number of places you have to work with code. There are lots of mechanisms for doing this, such as server-side includes, which allow you to include the contents of a common file into another.

However, there are cases in which you can minimize the total number of ASP files in your site by consolidating your code into one place. On the new ASP Techniques site, for instance, I have one file that is intelligent enough to show all the content on the site. Here’s the code from the Sub Main routine that runs first on the page. It’s just a Select/Case statement that checks the action codes and then calls the right routine. Each routine gets the appropriate key values to show the content, as well as a reference to an MTS component managing database access.

Sub Main
   Dim strAction     ' As String
   Dim lngSectionID  ' As Long
   Dim lngPageID     ' As Long
   Dim lngCategoryID ' As Long
   Dim lngContentID  ' As Long
   Dim strCommonID   ' As String
   Dim objDB         ' As NCSBackOffice.Database
   
   strAction = Request(ACTION)
   Set objDB = Server.CreateObject("NCSBackOffice.Database")
   Select Case strAction
   Case ACTION_RETR_COMMON
      strCommonID = Request("cID")
      RetrieveCommonContent objDB, strCommonID

   Case ACTION_RETR_SECT
      lngSectionID = Request("sID")
      RetrieveSection objDB, lngSectionID

   Case ACTION_RETR_CAT
      lngCategoryID = Request("cID")
      If Request("pID") = "" Then
         lngPageID = 1
      Else
         lngPageID = Request("pID")
      End If
      RetrieveCategory objDB, lngCategoryID, lngPageID
   
   Case ACTION_RETR_CONTENT
      lngSectionID = Request("sID")
      lngContentID = Request("cID")
      RetrieveContent objDB, lngSectionID, lngContentID
   End Select
   Set objDB = Nothing
End Sub
It’s all a matter of organization to do something like this. It’s not hard...it just takes some planning to make it work. If you’re interested in this sort of development, watch the ASP Techniques site for some upcoming articles about this topic.

Keywords: [ ASP Black Belt ]

Publication Date: 4/1/2000, Last Update: 2/12/2010