Recommended: Detailed explanation of the use of open method of xmlhttp open Create a new http request and specify the method, URL and verification information syntax of this request oXMLHttpRequest.open(bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword); Parameters bstrMethod http methods, such as: POST, GET, PUT and PROPFIND. Insensitive case. The URL address requested by bstrUrl can be absolutely
Starting from this article, the author starts with ASP built-in objects and analyzes the features and methods of the six built-in objects and various components of ASP for you in detail.
Before officially starting to learn the built-in objects and components of ASP, let us first understand some basic concepts, which will be of great help to your future learning. Please see the table below:
What is an object? It does not refer to the male or female companion you are in love. In object-oriented programming, an object refers to a variable composed of operations and data that are regarded as complete entities. Objects are based on a specific model in which the client uses the object's service to access the object's data through an interface of a set of methods or related functions, and the client can then call these methods to perform some operation. ActiveX components are key to building web applications, and components provide objects that perform tasks in scripts. An ActiveX component is a file that contains code that executes a certain item or set of tasks. Since the component can perform common tasks, programmers do not have to create code that performs these tasks themselves. Components can be leveraged as basic building blocks for scripts and web-based applications. As long as you know how to access objects provided by a component, even a newbie in scripting can write scripts without understanding how components work. In short, components allow you to write powerful scripts without learning programming. Components are executable code contained in the dynamic link library .dll or executable file .exe. Components may provide one or more objects as well as methods and properties of objects. To use the object provided by the component, create an instance of the object and assign the new instance the variable name. Use the Server.CreateObject method of ASP to create an instance of an object, and use the variable assignment directive of the scripting language to name the object instance. As shown in the following example:
Set db=Server.CreateObject(ADODB.Connection)
The variable db here is an instance of the object that accesses the database created by the ASP program.
Active Server Pages provides built-in objects that can be used in scripts. These objects make it easier for users to collect information sent through browser requests, respond to browsers, and store user information, thus freeing object developers from a lot of tedious work. The current ASP version provides a total of six built-in objects. Let's learn them through examples below.
1. Request object
You can use the Request object to access all information passed on any HTTP request, including parameters, cookies, and user authentication passed from HTML tables using the POST method or GET method. The Request object enables you to access binary data sent by the client to the server.
Request syntax:
Request[. Collection | Attribute | Method](Variable)
Here the author will select some commonly used object grammars for analysis
1. Form
The Form collection retrieves the values of the table elements sent to the HTTP request body by using the POST method.
grammar
Request.Form(element)[(index)|.Count]
parameter
element Specifies the name of the table element to retrieve the collection.
index Optional parameter, which allows you to access one of multiple values in a parameter. It can be any integer between 1 and Request.Form(parameter).Count.
Count Number of elements in the collection
The Form collection is indexed by the name of the parameter in the request body. The value of Request.Form(element) is an array of all element values in the request body. Determine the number of values in the parameter by calling Request.Form(element).Count. If the parameter does not associate multiple values, the count is 1. If the parameter is not found, the count is 0. To reference a single value in a table element with multiple values, the index value must be specified. The index parameter can be any number from 1 to Request.Form(element).Count. If one of multiple table parameters is referenced and the index value is not specified, the returned data will be a comma-separated string.
You can use the restater to display all data values in a table request. For example, a user fills out the form by specifying several values, see the figure below.
For the hobby parameter, you can retrieve these values using the script below.
<html>
< head>< title>< /title>< /head> < body>
< p> Please fill in your hobbies< /p>
< form method=POST action=form.asp>
< p>< input type=text name=hobby size=20>< br>
< input type=checkbox name=hobby value= Football> Football< input type=checkbox name=hobby value= Table Tennis> Table Tennis< /p>
< p>< input type=submit value= Send name=B1>< input type=reset value= Refill name=B2>< /p>
< /form>
< % For Each i In Request.Form(hobby) Response.Write i & < BR> Next %>
< /body>< /html>
Scrap the above code into the notepad (note that the spaces after < is removed), save it as a form.asp file and run it. The request object can display elements one by one according to the different contents of the element you fill in or select in the form.
Of course, using the For...Next loop can also generate the same output, as shown below:
< %
For i = 1 To Request.Form(hobby).Count<
Response.Write Request.Form(hobby)(i) & < BR>Next<
%>
2. QueryString
The QueryString collection retrieves the value of a variable in an HTTP query string, and the HTTP query string is specified by the value after the question mark (?). like:
< A HREF= example.asp?string=this is a sample>string sample< /A>
Generates a variable name string with the value this is a sample. Query strings can also be generated by sending a table or by the user typing a query into the address box of his browser.
grammar
Request.QueryString(variable)[(index)|.Count]
Share: A complete collection of commonly used custom functions for ASP % '====================================== 'Function list: '1: Establish a connection to the database ConnOpen(DataBaseConnectStr,DBType,Conn_object) '2: Disconnect the connection to the database ConnClose(Conn_object) '3: Prevent SQL injection of SafeRequest(paraName,paraType) '4: Format the date DateFormat(dateStr,dat
2 pages in total Previous page 12 Next page