Using ASP with Templates

Why should we use Templates and what are they ? Templates are simply a skeleton structure of a group of pages on your site, that have a common layout style, but contain some unique elements or values. A template is simply a webpage that has been created but has no actual 'content', similar to a 'mail-merge' letter before you add the data to produce the output letters.

For many companies, their web development team is seperated into two distinct camps - developers (those who code) and designers (those who make the output look nice). In many cases developers are also looking for simple ways to develop a complex website. This site uses two template types, the first is a HTML template that defines the basic layout of the page - this is achieved using standard HTML tables - the second uses Javascript to add a consistant Header bar - including menu - and footer to all the pages. In this example, we are going to develop a simple template and then populate it using ASP and investigate the advantages and some of the options of this approach.

Lets start by designing our template HTML page. This page needs to contain the skeleton for our site and some identifiable tags which we can later replace with the output of our ASP, exmaples of this could include the following :

At this point, we need to define how we will identify the special tags that we will use to identify the places where we want data to appear when the page is merged with the output of the ASP. For this example we will use curly brackets - {} - around the field names. We don't have to worry about using these brackets for other things as we will only be replacing the variables that we are generated in the ASP. However, in some cases where you may be using a template with several different output options, you may have to set several fields to be replaced by a space so that they don't appear on the output as {fieldname}. Taking all this into consideration, we have a template which looks like the following file.

In the next section, we will look at how we use ASP to read in the template file and replace it with some static data and then some data from a database.

Website Designed by Adservio Consulting Valid HTML 4.01 Strict    Valid CSS!    Level A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0