INFO: Breakdown of Data Form Wizard Code

ID: Q172926


The information in this article applies to:
  • Microsoft Visual InterDev, version 1.0


SUMMARY

Microsoft Visual InterDev provides a Data Form Wizard for the generation of sample Active Server Pages (ASP) for simple data management. This article breaks down how these pages function so that users may better understand them if they wish to make changes to add functionality.

NOTE: Microsoft Technical Support does not directly support any changes made to the code produced by the Data Form Wizard. Changes rendered are considered to change the code from "Wizard" code to "User" code and are supported as if it were a user written application.


MORE INFORMATION

When completed, the Data Form Wizard will produce three files. These files will be named with the following conventions:


   xxxxForm.asp
   xxxxList.asp
   xxxxAction.asp 
xxxx represents the name given when the Data Form Wizard is selected from the New menu command on the File menu.

All of these files follow a similar format. Each file contains a set of initial <SCRIPT></SCRIPT> tags that contain the various functions and procedures called by the page. Following this section is the body of the document. This is the HTML code and ASP code that is then processed sequentially.

xxxxFORM.ASP And xxxxLIST.ASP

In xxxxForm.asp (hereafter referred to as Form.asp) and xxxxList.asp (List.asp) the body of the document contains four main sections:
  • Heading Section


  • Data Range Header


  • Field display code


  • Data Range Footer


Heading Section:

The heading section is responsible for displaying the various actions that are valid for the form. This code checks for what state the form is in and displays the appropriate buttons. The state of the form can vary between being in edit mode, filter mode, and display. Each button displayed is a submit button that calls the xxxxAction.asp.

Data Range Header:

The Data Range Header (DRH) is simply code produced by the Data Range Header design-time control. This section of code is delimited by the following tags:

   <!--METADATA TYPE="DesignerControl" startspan 
-and-

   <!--METADATA TYPE="DesignerControl" endspan --> 
To change any of this code you can right-click within this area and choose the "Edit Design-time Control" option. Note that you can change the fields that are included in the form here, but doing so is not sufficient to affect changes in the rest of the form. This must be done manually. More information on this will come later.

Some key settings to note on this design-time control:
  • Record Paging is Enabled


  • Record Paging Size for Form.asp is 1, List.asp is 10


  • Range Type for Form.asp is Form, List.asp is Table


  • Both List.asp and Form.asp require that the CursorType NOT be ForwardOnly in order for paging to function properly.


Data Range Footer:

The Data Range Footer (DRF) is similar to the Data Range Header. Towards the bottom of both of these documents you will find similar sections delimited by another set of the same tags. Be careful not to mistake the endspan tag of the DRF as the endspan of the DRH. This control is responsible for ending the data section and displaying the navigation buttons, which are all submit buttons that call xxxxAction.asp. When ending the data range when the Data Range Header has a Paging Size greater than 1, it causes the form to loop back and process any information contained between the DRH and DRF. This is what allows the List.asp to display 10 records at a time.

Field Display Code:

This section of the document is between the DRH and the DRF. It contains all information that is displayed on each pass through the loop established by the DRH and DRF. In the case of the Form.asp this happens only once, and consequently only one record is displayed.

In both the List.asp and the Form.asp this code is simply a set of calls to a function defined at the beginning of the page: ShowField. This function accepts four parameters. These parameters define what the name of the field is, the description text, whether or not the field is an Identity/Autonumber field, and finally an optional array if you wish to display the field as a drop-down list box. In the ShowField function these are defined as follows:

   strFieldName, strLabel, blnIdentity, avarLookup 
strFieldName: The fields to be displayed by calling ShowField must be part of the Recordset fetched by the DRH. This field is passed as a string and is the exact name of the column in the Recordset.

strLabel: This is a text string representing the text that will be displayed as a column heading in List.asp and next to the text box in Form.asp.

blnIdentity: This is a Boolean (true/false) value indicating whether or not the field is an autonumber or identity field. These are automatically calculated and consequently not editable.

avarLookup: This is not accessible through the Data Form Wizard interface and must be adjusted in the form itself. ShowField looks for a two- dimensional array to be passed in this variable. The first column of data in the array should be an index, while the second column contains the data to be displayed instead of this index when editing. The form displays a drop-down list box in place of the field so that a user may select from the values in the second column of the array passed to ShowField.

The ShowField function examines the field passed to it and determines how it should display it. How the field is displayed depends upon what data type it is, and whether the form is in edit mode or not.

xxxxAction.asp

This file is responsible for processing all button presses from either the List.asp or Form.asp. It to begins with various functions defined in the <SCRIPT></SCRIPT> tags. The body of this page performs one of two basic actions. Either it will process the command and then load one of the other two forms, or it will display information. The information displayed will either be a confirmation of an action you performed, or information about an error that has occurred.

In the Action Handler section of this page, the VBScript code checks to see which button was used to call the page, and act accordingly.


REFERENCES

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:

http://support.microsoft.com/support/vinterdev/

Additional query words:

Keywords : kbsample kbwizard kbVBScript kbVisID kbVisID100 kbGrpASP
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: November 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.