ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
148 active users
3108 visitors today
4670 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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

Selling products online - read how James does it now


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