Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Object oriented ASP --> Part 3: A sample page

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
15 active users
41 visitors today
158 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

But first...

Before showing a working sample page I'll admit the real classes have a little more code in them than I've shown so far, but only very little.

For example, the HeadOut() function also contains this code, to optionally output a title if one is given..

// output title if one exists
if ( this.sTitle != null )
   Out ( '<title>' + this.sTitle +'</title>' );

..and in common with many of the other classes, BodyOut contains this code:

// output content if there is any
if ( this.Content != null )
   this.Content ( );

A sample page

So here is a sample page that uses my new classes. Not the same as your average asp page perhaps?..

<%@ Language=JavaScript %>
<!--#include file = "utils/PageClasses.asp"-->

<%
oPage.Head.sTitle = 'hello';

oPage.Body.Content = function ( )
{
   Out ( '<p>Some body content goes here' );
   Out ( '<h3>Close this window to continue..</h3>' );
}

oPage.Out ( );
%>

Skipping the first two (hopefully obvious) lines, I set the title of the page, then create a function "on the fly" and assign it to the Body.Content member.

Lastly, I call the oBody.Out function, which is the only line that does any work! See the result...

In conclusion

You can see the entire source code for this article by clicking on the icon below. There are many more clever things you can do using the methods shown in this code - it certainly opened my eyes a little wider!

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems


CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...