Blog Tools
Edit My Blog
RSS Feed RSS
About Me
Contact Me

< < Mar 2011 > >
S M T W T F S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
You are not signed in.
Sign in

Entries By Topic
·All Topics RSS
·Classic ASP RSS
·CSS RSS
·Databases RSS
·eBay/PayPal RSS
·General RSS
·Hardware RSS
·Web Security RSS
·Windows XP RSS

Search
 
Recent Entries
·Classic ASP Master Pages
·eBay encourage/force you to lose money on postage
·CAPCTHAs and alternatives
·Obtaining Image Properties in ASP Without a Component
·New Microsoft Hotmail good reason not to use Microsoft Explorer
·Why are most real estate agents so bad at selling online
·Classic ASP Title Case
·Does stopfax.com.au really stop junk faxes?
·SQL Injection Protection - b.js
·Unfair eBay fees for used cars

John's Technology Blog

Classic ASP Master Pages

Posted at: March 27, 2010
Related Topic(s): Classic ASP

Click here for daily freebies, competitions, surveys and the best offers - OUTPOSTOFFERS.COM - Australia

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">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<% Call HeadPlaceHolder() %>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script language="javascript" type="text/javascript" src="/java.js"></script>
</head>
<body>
<div id="header">
Logo etc etc
</div>
<div id="content">
<% Call ContentPlaceHolder() %>
</div>
<div id="footer">
Copyright etc etc
</div>
</body>
</html>

content-page.asp

<%
'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" />

<% End Sub %>

<% Sub ContentPlaceHolder() %>

<p>My page content goes here</p>

<% End Sub %>

View Comments (2) | Add Comment | Permalink

stop faxing me sola 0746961711 please

Posted by margaret miller | May 11, 2010

since using the stop faxing me link, i have been inundated with useless faxes, i only hope an email to cbox will stop them finally, i have had enough

Posted by Deb | June 8, 2010

Newer | Latest | Older

Free automotive classifieds, reviews, etc

Car and motorcycle books and repair manuals

ASP Hosting and Domain Names

For cheap asp and asp.net hosting I recommend CrystalTech, for cheap .com domains Cheeky Domains, or for .com.au domains Name Scout.

[Oztion is an Australian auction website which offers no listing fees]