Wise ASP Logo Surfer's Choice Member
   

Wise ASP - ASP Template

Here you will learn to layout a ASP page so that it reads as easily as a typical computer program. You will not have to worry about embedding all of those ASP tags in your html which can cause a performance degradation and a maintenance headache. Use the comments in each section to understand how each is used.

---- START TEMPLATE ----

<%@ Language=JScript %>                // Always specify the language 
///////////////////////////////////////////////////////////////////
//
// filename.asp
// 
// File name should be short, descriptive, lower case and no spaces.  
// All .asp and .htm file name should be assigned in 
//  advanced by the site designer.
// 
// mm/dd/yy Update Description
// 
///////////////////////////////////////////////////////////////////

<!-- #include file="header.asp" -->
<% main() %>
<!-- #include file="footer.asp" --> // Include reusable footer code
<SCRIPT LANGUAGE=JSCRIPT RUNAT=SERVER> // Always specify the language
/////////////////////////////////////////////////////////////////// // // debug(str) should be hard coded on each page so you can control // debugging on that page. Call debug(str) on all sql statements // before you execute them. // // Parameter: str - the string to output to the user // function debug(str) { // Comment the call to Response.write in order to disable debugging. Response.write("<PRE><FONT COLOR=BLUE>" + str + "</FONT></PRE><P>"); }
/////////////////////////////////////////////////////////////////// // // writeErrorMsg(str) is an optional function that can be used to // display an error message on a page // // Parameter: str - the string to output to the user // function writeErrorMsg(str) { Response.write("<PRE><FONT COLOR=RED SIZE=5>" + str + "</FONT></PRE><P>"); }
/////////////////////////////////////////////////////////////////// // // getStringField(str) is an optional function that can be used to // convert JScript "null" and "undefined" to a string. This // function is very useful for all Recordset fields. Remember // a Recordset field is not a string as it is returned from // SQL. // // Parameter: theRSField - the parameter to convert into a string // function getStringField(theRSField) { var theStr = String(theRSField); if (theStr == "null" || theStr == "undefined") return ""; else return theStr; }
/////////////////////////////////////////////////////////////////// // // write(str) is a shortcut for Response.write(). It should be // hardcoded on each page because it's nearly always used. // // Parameter: str - the string to output to the user // function write(str) { Response.write("str \n"); }
/////////////////////////////////////////////////////////////////// // // main() will contain all of the page's logic, including calls to // other functions. Because of all the nitty-gritty details are // in the worker functions, try to make the purpose and logic // of main() self-evident // function main() { startFunc(); if ( evaluate ) { dothis(); } else { dothat(); } } /////////////////////////////////////////////////////////////////// // // JScript worker function(s) used by main() // // function doSomething(par1, par2) { var tmp; ... return tmp; } <%/SCRIPT %>

---- END TEMPLATE ----

  That's the end. Feel free to cut and paste this code and use it yourself. Thanks for reading and feel free to jump around Wise ASP using the select box at the top of the screen.

88x31cardsvisoranm