This document summarizes the core include files required by our ASP web sites. This core is regarded as mature and stable and should require little modification. This is good news in view of the establishment of Microsoft’s new ASP.NET technology. Ideally, these words mark our formal departure from the “classic” ASP world, allowing research in .NET technology to go forward on a firm foundation.
The image at left shows the core ASP in the Visual Studio.NET Solution Explorer. We have three folders:
\inc folder, containing constants.\inc\classes folder, containing VBScript and PHP classes.\inc\routines folder, containing frequently-used, generic VBScript routines and generic, client-side JavaScript.The root folder (\inc) is usually at the root of the web site and is called by a #include virtual directive.
A small but vociferous minority has innocently posed the question, “Why use VBScript on the server side instead of JScript?” The question usually comes from a person who was not brought up on a healthy diet of calorie-rich Microsoft products. This kit is designed with a large population of Visual Basic and VBA programmers in mind. Back in the late 1990s, when this kit was first starting out, these folks were the blokes claiming “ASP/IIS” experience in the resumes. So, in an effort to play well with others, VBScript was selected to make sure that the majority could hit the ground running.
\inc Folder| File Name | Description |
|---|---|
ADOVBS.asp | Constants used with Microsoft’s ActiveX Data Objects (ADO). This file shipped with IIS (under a different file name). |
CDOVBS.asp | Constants used with Microsoft’s Collaboration Data Objects for New Technology Services (CDONTS). For us everyday folk this file was needed when you wanted to use ASP to send an email. The contents of this file is also directly from Microsoft. |
rasxADO.asp | Constants used with our customized COM object used to streamline ADO calls. This object is discussed in detail in “Developing a Customized COM Object for ADO.” By the year 2000, this file and its associated COM object was not used anymore in lieu of the ADO.asp VBScript class file discussed below. |
\inc\classes\ADO.asp FileThis file contains the VBScript class, clsADO, which was translated from the ActiveX object discussed in “Developing a Customized COM Object for ADO.”
| Property/Method | Description |
|---|---|
Connection | Gets the ADO Connection object associated with the instantiated object of this class. |
DataErrText | Gets the errors collected by the private basDataErrMsg() method. |
RecordsAffected | Gets the records affected by the last command run against the ADO Command object via CnnCmd() or StoredProcCmd() (if this feature is supported by the OLEDB Provider). |
HasRecords | Gets the Boolean after the test for whether an ADO Recordset object contains records. |
Connect() | Gets the Boolean after the test for connecting to the data source with the following arguments:
TIP: By omitting the |
CnnCmd() | Gets the Boolean after the test for successfully executing dynamic SQL commands against the
|
CnnRst() | Executes dynamic SQL projections against the This method has the same arguments as |
ClientRst() | Returns a disconnected, ADO Recordset ( This method has the same arguments as |
StoredProcCmd() | Gets the Boolean after the test for successfully executing a stored procedure against the
NOTE: This value is passed by reference ( When The 2D parameter array has the following form: <param’ name>, <row 0> <param’ value>, <row 0> <param’ name>, <row 1> <param’ value>, <row 1> etc.
|
StoredProcRst() | Executes a stored procedure against the This method has the same arguments as |
CloseRecordset() | Closes the specified recordset object and sets the object to
|
Disconnect() | Closes the ADO connection object. |
\inc\classes\FileSystem.asp FileThis file contains the VBScript class, clsFileSystem, which handles routine calls to the file system via the Scripting.FileSystemObject and, because these calls are from ASP, the MSWC.PermissionChecker (referred to as the Permission Checker Component in the Windows 2000 Advanced Server documentation). This is a VBScript class (instead of a stateless set of routines) because, like clsADO, it is convenient to “open a connection” to a folder and “query” it several times at runtime.
| Property/Method | Description |
|---|---|
ErrMsg | Gets any trappable VBScript error messages. |
FSO | Gets the Scripting.FileSystemObject created by the class constructor. |
Permissions | Gets the MSWC.PermissionChecker object created by the class constructor. |
WebFileName | Gets/Sets the name of a file. No path information should be set here. |
WebFilePath | Gets/Sets the path to the file set in WebFileName. This string literal must end with a backslash, \. |
WebFileExists() | Gets the Boolean result of the test checking for the existence and/or permissions of a file with the respect to IIS. A file object must be pre-defined by setting the WebFileName and WebFilePath properties. |
WebFileObject | Gets the file object associated with the call to the WebFileExists() method. The implied rule here is, You cannot have a file object without first checking for its existence. |
WebFileSize | Gets the size in bytes of the file object associated with the call to the WebFileExists() method. |
WriteFile() | Gets the Boolean result of the test for successfully writing to a text file with the argument:
A file object must be pre-defined by setting the |
\inc\classes\HTMLComboBox.asp FileThis file contains the VBScript class, clsHTMLComboBox, which renders HTML select elements, described in Microsoft-speak as “list boxes” or “drop-down boxes.” It will be stated with pride that this method of rendering HTML was “discovered” independently and almost predates the public introduction of .NET server-side controls. It is quite a reassuring feeling that Microsoft was on the same page as our little organization—although there should be some debate about the size of this page!
| Property/Method | Description |
|---|---|
ClassName | Gets/Sets the By default, the |
DefaultSelected | Gets/Sets the Boolean property that determines if the default value ( NOTE: The client-side JavaScript function |
ID | Gets/Sets the By default, the |
JavaScript | Gets/Sets inline JavaScript used by the EXAMPLE: To add the Set objCombo = new clsHTMLComboBox
objCombo.JavaScript = _
"onChange = ""[your code here]"""
You can see how we are using the old VB double-quote trick to render the quotes in HTML. You can also see how free-form this property can be which makes it very dangerous to inexperienced users. By default, inline JavaScript is not rendered in the HTML. |
Name | Gets/Sets the By default, the |
IsMultiSelect | Gets/Sets the Boolean property that determines if this By default, the |
Recordset | Gets/Sets the ADO recordset object used to create option elements for the select element. Only the first two columns of this recordset are used. By default, the leftmost column (column 0) sets the value attribute of the option element and the second column (column 1) is displayed. |
RevColumnOrder | Gets/Sets the Boolean property that determines if the column order of the recordset or array is reversed. This means that column 1 sets the This property is useful for those unfortunate cases when you are not in control of the data being sent to the client from the DBMS. |
Size | Gets/Sets the size attribute of the select element. By default, it is 1 (making a drop-down box); values greater than one make the list box. |
Width | Gets/Sets the By default, this property is not used and is usually ignored because of the use of the |
ValueList | Gets/Sets the string literal used to create [value] & vbNullChar & [display text] … This implies that odd-number values in the list set the |
GetComboBox() | Returns an HTML string based on the properties set above. This method should only be used when the Recordset property is set. |
GetComboBoxValLst() | Returns an HTML string based on the properties set above. This method should only be used when the ValueList property is set. |
\inc\classes\HTMLPage.asp FileThis file contains the VBScript class, clsHTMLPage, which renders entire HTML pages and common interface elements. This class was replaced by the \inc\routines\uiServices.asp file mentioned below. This class was just not flexible enough but is mentioned here for the sake of completeness and will not be documented in detail.
\inc\classes\HTMLTable.asp FileThis file contains the VBScript class, clsHTMLTable, which renders entire HTML tables. This class is the workhorse of the core and is discussed in detail in Using a Generic, Stateless VBScript Object to Display Data in a Tabular Format.
\inc\routines\appServices.asp FileThis is the “web application services” file containing generic, frequently-used VBScript routines.
| Routine | Description |
|---|---|
basDisplayHTML() | This function truncates the text to be displayed as HTML at the specified length with arguments:
NOTE: Ellipses are appended to the end of a non-zero-length truncated string. |
basGetGMTOffset() | This function returns the Greenwich Mean Time “offset” with respect to Pacific Time. It returns 7 when Pacific Standard Time is detected and 8 when Pacific Daylight Savings Time is detected. This function is rather useless out of the Pacific time zone. It was developed for writing vCalendar items. |
basGetMonthNames() | This function returns a one-dimensional array of month names based on the locale settings of the web server with the following argument:
|
basGetWeekDayNames() | This function returns a one-dimensional array of weekday names based on the locale settings of the web server with the following arguments:
|
basGetWeekDate() | This function returns a date based on these arguments:
NOTE: This function assumes that the first week of the year the week in which January 1 occurs |
basGetVPath() | This function returns the virtual path in the SCRIPT_NAME environment variable as an array or as a scalar identified by
|
basIIf() | This function is the VBScript equivalent of VBA.IIf() with arguments vCondition, vTrueResult and vFalseResult. |
basInArray() | This function searches an array for a scalar value with arguments:
NOTE: This converts the search scalar and each array element to strings for each search attempt. |
basIsAgent() | This function is a server-side browser sniffer with argument
NOTE: Our client-side browser sniffer ( |
basLogonUser() | This function reads the When When All other values return the unaltered contents of the |
basRandomNum() | This function returns a random integer from LowerLimit to UpperLimit. The OmitList argument, a comma-delimited list of integers, is used to prevent random values matching one of the integers in the list from being returned. |
basDelaySec() | This function delays code execution for the amount (in seconds) indicated by This function is most useful when the |
\inc\routines\rootData.js FileThis is the “root” file of client-side JavaScript routines that handle generic data binding and validation for web-based data editing forms.
| Routine | Description |
|---|---|
jsGetOptionsIndex() | This JavaScript function returns an integer value indicating the index of one of the
This data binding function is essentially used to set the |
jsGetRadioValue() | This JavaScript function returns the value of the checked radio button in an array of radio buttons with the argument objRadio, the input object of type=radio as seen by the DOM. |
jsGetWildCard() | This JavaScript function concatenates the wildcard character (
This function is made to be a part of a search form. |
jsIsEmailValid() | This JavaScript function returns a Boolean value, testing the validity of email addresses with arguments:
|
jsIsNotComplete() | This JavaScript function returns a Boolean value, testing for text entered in an
If the text field is not complete, this function returns |
jsIsNotNumeric() | This JavaScript function returns a Boolean value, testing for a numeric value entered in an If the value entered is not numeric, this function returns |
jsIsNotSelected() | This JavaScript function returns a Boolean value, testing for an item selected in an It has the same arguments as If the item is not selected, this function returns |
jsIsTextConfirmed() | This JavaScript function returns a Boolean value, testing for identical values entered in two
If the text fields do not contain the same value, this function returns |
jsIsTextLength() | This JavaScript function returns a Boolean value, testing for the length of text entries into If the text entered exceeds the maximum value, this function returns |
jsIsUniqueOption() | This JavaScript function returns a Boolean value, testing for unique
If the value is unique, this function returns |
\inc\routines\rootDates.js FileThis is the “root” file of client-side JavaScript routines that handle a client-side date picker. This date picker is still under development and will be documented in a future publication.
\inc\routines\rootMenu.js FileThis JavaScript comes from Macromedia’s Andy Finnell and is used by Fireworks to make drop-down, hierarchical menus. This is another “experimental” item and may be documented later.
\inc\routines\rootSniffer.js FileOur client-side JavaScript browser sniffer (rootSniffer.js) from webreference.com.
\inc\routines\stringServices.asp FileThis VBScript file contains string handling routines. This, the oldest file of the core, was translated out of Visual Basic 6.x and 4.x (before that, translated out of Access 97!). Many of the string handling functions were removed as Microsoft improved upon VB, VBA and VBScript. Many more functions should be replaced since the advent of Regular Expressions in VBScript (evidently introduced around 1999).
| Routine | Description |
|---|---|
basGetCharPos() | This function returns the character position of the first character in the search string ( So far, this function is very similar to If |
basGetDigits() | This function returns Arabic numerals out of and will return “periods” (assumed to decimal points) if argIncludeDecimal=true. |
basGetSubStr() | This function returns a substring out of
These arguments can be used in any combination allowing some flexibility and some primitive form of pattern matching. However, this function is to be considered obsolete for those who can use regular expressions. When a particular parameter needs to be “turned off,” use the following default values: argStartCol = 0 argEndCol = 0 argStartChar = vbNullString argEndChar = vbNullString |
basSearchLine() | This function returns the line containing In other words, this function responds to the request saying, “Show me the entire line of text containing the search string.” |
basInsCrLf() | This function inserts This function was very useful back in the days when lines of text in email messages needed to be a certain length. |
\inc\routines\uiServices.asp FileThis VBScript file contains “user interface services” common to many web sites. This is sort of a “smart” include file that contains one subroutine, basIncludeHTMLBlock() that takes two parameters: vBlockName and vBlockValue. The first parameter calls a particular block of HTML and the second parameter passes content that changes from call to call. The following table summarizes some the common HTML blocks:
| Block Name | Description |
|---|---|
!BOF_begin | Returns the “beginning of HTML file” block. This contains the DTD and the VS.NET, VS_TARGETSCHEMA tag. The target schema tag makes it easy to maintain the uiServices.asp itself because it provides Intellisense and other VS.NET features. So far, not much “service” for the “user.” |
!LINK_css | Returns a link tag calling an external CSS file. By default, it will call ./root.css. If vBlockValue is not a zero-length string then it must be relative or absolute path to an external CSS file. |
!META | Returns meta tags used by search engines. This routine makes all web pages of a particular site have identical meta identification tags. |
!SCRIPT_js | Returns a script tag calling an external JavaScript file. By default, it will call ./root.js. If vBlockValue is not a zero-length string then it must be relative or absolute path to an external JavaScript file. |
!BOF_end | Returns the end of a “beginning of HTML file” block. This contains When an “error page” is called from ASP code this HTML block is useful in making a complete web page. See below for more details. |
Page | Returns a complete HTML page by calling this subroutine recursively. This is used mostly for ASP “error pages” so This kind of call should not be made from an ASP page if the calling page is already rendering HTML. |
!EOF | Returns the ending tags of an HTML page. |
Our designs usually have blocks like Header or Footer. Clearly, the intention here is to centralize the handling of look and feel for web sites—even when errors are being handled. A page like this is easier to maintain with Visual Studio.NET than the VBScript class HTMLPage.asp file mentioned earlier. In fact, a web designer can create that wonderful header or footer in static HTML (like in Dreamweaver or even FrontPage) only to have it copied and pasted into a dynamic page like this one.
The publishing of this document in public on the Internet marks a fond farewell to an era of ASP. This lengthy summary (which is 16 pages in Microsoft Word) records years and years of pain, misery and triumph. Now we move on to ASP.NET! Microsoft promises that this new technology will not bring as much suffering as ASP classic. In fact, the code is supposed to document itself, making pages like these obsolete.
| Download | Description |
|---|---|
| rasxASP.zip | The \inc folder and the files mentioned above. |