Share via


Implementing the Main Subroutine for Solution Sites

Every page you author that uses the standard page execution model supported by the Solution Sites must implement a routine called Main (implemented as a sub rather than a function). This routine is called near the end of the processing in the file include\setupenv.asp. The routine Main has several responsibilities, as follows:

  • Initialize the variable htmPageContent, which is defined in the include\setupenv.asp file. This variable should be initialized to a string containing the HTML that you want rendered in the content area of the page you are authoring.
  • Where appropriate, initialize the variable htmDiscountBannerSlot, which is defined in the include\setupenv.asp file. This variable should be initialized to a string containing the HTML that you want rendered in the discount area of the page you are authoring.
  • Where appropriate, initialize any additional variables that have been defined to pass HTML content between the routine Main and a customized layout file.
  • Whatever other processing is appropriate for the page you are authoring, such as adding items to the basket, performing checkout processing, and so on.

For example, perhaps the simplest implementation of the routine Main looks something like this:

Sub Main
    htmPageContent = "This is the content area."
End Sub

Another example, which displays the same string in bold font, looks something like this:

Sub Main
    htmPageContent = "This is the content area."

    ' Function Bold from include\html_lib.asp
    htmPageContent = Bold(htmPageContent)
End Sub

Realistically, the routine Main will be much more complex, often involving calls to Commerce Server objects, and to the various utility routines that are available when the files in which they are implemented are included in the page you are authoring. It is important to familiarize yourself with both of these types of resources so that you do not spend unnecessary time re-writing functionality that already exists. Unfortunately, there is no effortless way to gain this familiarity other than by the careful reading of the supplied documentation and examination of the existing code for the Solution Sites.

There are numerous examples of Main routines throughout the pages of the Solution Sites. You should study a number of these to familiarize yourself with how the HTML content assigned to the variable htmPageContent is created in the pages that already exist.

See Also

Implementing Support Routines for Solution Sites

Page Execution Model for Solution Sites

Copyright © 2005 Microsoft Corporation.
All rights reserved.