When developing websites most of them have common elements like headers, footers and navigational menus that are common throughout the site. In Classic ASP we mostly use multiple server side includes to accomplish this. I like ASP.NET master pages and this page details the technique I use to achieve something similar in Classic ASP.
My technique involves creating a master page ASP file which has all the common elements. Where ever I want content to be added I add a call to a sub routine.
Then in my content pages when I want the master page content to be added I include it at that point. I then create a sub routine for each content area and put my content inside these. You can have as many content sub routines as required but they must exist in every content page that uses that master page.
The following example shows a master page and content page with two content areas: one inside the head tag (called HeadPlaceHolder in this example) so I can easily add title and meta tags, and add JavaScript and CSS within the head tag if required; and one inside the body tag between the header and footer (called ContentPlaceHolder in this example).
Any ASP variables that are needed by more than one content area should be created outside of the sub routines.
masperpage.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<% 'Any ASP variables that are needed by multiple contenbt areas should be declared 'outside of the sub routines 'It's a good practice to keep your ASP script at the beginning of your pages anyway %> <!--#include virtual="masterpage.asp"--> <% Sub HeadPlaceHolder() %>
<title>My page title</title> <meta content="My meta description" name="description" />