Previous in Contents Next in Contents

The Page Object's Request Methods

The Page object supports a group of methods whose names begin with Request. These methods apply locale-based data type conversion and value range-checking to values retrieved from the client browser, either from a URL query string or form. Performing these operations on user input ensures that values retrieved through a page can be inserted without error into the site's database storage or passed to the order processing pipeline (OPP) in an OrderForm object without generating pipeline or page syntax errors.

The following example illustrates how to use one of these methods, RequestDate, to perform locale-based data type conversion and range validation on a URL query string.

This example assumes that the date value is entered using the following form:

<FORM METHOD ="POST" ACTION="PROCESS.ASP">
<INPUT TYPE="Text" NAME="Date">
<INPUT TYPE="SUBMIT" NAME="ACTION" VALUE="Send Info">
</FORM>

If the user enters the date into the form and clicks the Send Info button, the value of this form field can be retrieved by the RequestDate method as follows:

StrDate = Page.RequestDate("Date", "2/27/98", "1/1/98", "12/31/98")
If IsNull(StrDate)
    REM    RequestDate failed.

The first parameter to RequestDate specifies, in this case, the name of the form field from which the data was submitted. If this text field is empty, the second parameter to RequestDate, "2/27/98" becomes the date that RequestDate processes. First, the string expression of the date is converted to a date value based on a specified locale, and then the value is checked against the specified date range specified by the third and fourth parameters. In the previous example , this locale is not specified, so RequestDate uses the value of the DataFunctions object's Locale property as the basis of the conversion.

The following table shows the value returned under different conditions.

Condition Method returns
Value is present in requested data and is valid. Value returned from the URL query string or form post variable.
Value returned is empty or Null (for example, the customer did not type a value in the field), or variable does not exist in requested data. Default value (Null, or the value specified by the Default parameter if specified).
Value returned is out of specified range. Null.
Value returned is invalid according to rules for locale. Null.


© 1997-2000 Microsoft Corporation. All rights reserved.