Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 36,643 times

Contents

Related Categories

Creating a Template - Creating the template

cheesekeeper

Creating the template

Now we must divide the code into two parts, the header and the footer. Basically, everything before the "Content goes here." placeholder is the header, and everything after it is the footer. Once you've broken the HTML code into these two parts, create a new ASP file and stub in two subroutines named Header and Footer, like this:

<% Sub Header(title) %>
<% End Sub %>

<% Sub Footer() %>
<% End Sub %>

You'll notice that the Header subroutine has one parameter, title. This is so we can pass the title of the page into the subroutine so that it can insert it into the template. Now put the HTML code into the subroutines. In the places where the title should go in the header, put instead the code <%=title%>.

<% Sub Header(title) %>
<html>
  <head>
    <title><%=title%></title>
  </head>
  <body>
    <table cellpadding="6" cellspacing="0" border="0">
      <tr>
        <td colspan="2" bgcolor="#aaaaff">
          <big><b><%=title%></b></big>
        </td>
      </tr>
      <tr>
        <td valign="top" bgcolor="#aaaaff" nowrap>
          Nav 1<br>
          Nav 2<br>
          Nav 3
        </td>
        <td valign="top" bgcolor="white">
<% End Sub %>

<% Sub Footer() %>
        </td>
      </tr>
    </table>
  </body>
</html>
<% End Sub %>

It's often good practice to save templates and other files that are included by your pages in a separate directory. I called mine "include", so let's save our template as "/include/template.asp".

Comments