ASP 3.0 advanced programming)

Source: Internet
Author: User
Tags abs html form
6.2.10 Tools components
The Tools component provides some useful methods to check whether a file exists on the page, process an HTML form, generate a random integer, and some methods for Macintosh computers, you can also check whether a server plug-in exists and whether the user is the website owner.
1. Page-based Tools components
The Tools component provides five methods, two of which depend on the operating system, as shown in Table 6-8:
Table 6-8 methods and descriptions of Tools
FileExists (relative_url)
If the file specified by relative_url exists, the return value is True; otherwise, the return value is False. The virtual relative path and file name must be provided, and the file must exist in the published Web site directory.
Random ()
Generate ~ A random integer between 32767. Use the ABS function (VBScript) or Math. abs (JScript) to obtain ~ A positive integer between 32768. Use the Mod operator (VBScript) or the % operator (JScript) to obtain a value in the specified range. For example:
IntRand = (objTools. Random Mod 76) + 25
Get ~ An integer between 100.
ProcessForm (output_url,
Template_url, [insertion_point])
Process an HTML form using the file specified by template_url, and insert the value from the form that has been submitted to the current page. The result is written into the file specified by output_url. If the insertion_point (string) parameter is specified, the component can find this string in an existing output file, insert new content at this location. If the insertion_point parameter is not specified, any existing output_url file will be replaced by the new output.
Only applicable to Macintosh hosts. If the current user account is the Web site owner, the return value is True; otherwise, the return value is False.
PluginExists (plugin_name)
Only applicable to Macintosh Machines. If the specified server plugin_name is installed on the machine, the return value is True; otherwise, the value is False.
2. Use the FileExists method
Before allowing user access, you can use the FileExists method to check whether some files exist on the server (note that this method works in the same way as FileSystemObject. FileExists ).
In the following example, the user provides the relative URL of the webpage. If you want to open the webpage by typing a URL in the text box named txtURL, you can check whether the webpage exists before redirecting.
<% // In Jscript:
Var objTools = Server. CreateObject ('mswc. Tool ');
Var strURL = Request. Form ('txturl'); // collect the page URL they entered
If (objTools. FileExists (strURL) // see if it exists
Server. Transfer (strURL) // if it does, transfer to it
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.