Introduction to six ASP objects (1)

Source: Internet
Author: User
Application object
An Application object is an Application-level object used to share information among all users and maintain data permanently during Web Application running.
Application attributes:
The method is as follows:
The Application object does not have built-in properties, but we can create its own properties.
<% Application ("Property Name") = value %>
In fact, most Application variables are stored in the Contents set. When you create a new Application variable, you actually add one in the Contents set. The following two scripts are equivalent:
<% Application ("greeting") = "hello! "%> Or <% Application. contents (" greeting ") =" hello! "Because the Application variable exists in the set, if you want to display it all, the method has been used multiple times, For example, For Each loop.

<%
For Each item IN Application. Contents
Response. write ("<br>" & item & Application. Contents (item ))
Next
%>
Application method:
The Application method has only two methods: Lock and Unlock. The Lock method is used to ensure that only one user can operate on the Application at the same time. Unlock is used to cancel the Lock method restriction. For example:
<%
Application. Lock
Application ("visitor_num") = Application ("visitor_num") + 1
Application. Unlock
%>
Application event:
1. Application_OnStart ()
Triggered when the event application starts.
2. Application_OnEnd ()
This event is triggered when the application ends.
The two event processes must be defined in the Global. asp file. Generally, the function that connects data is defined in these two events and then stored in Global. asp. For example:
Sub Application_OnStart
Application ("tt18_ConnectionString") = "driver = {SQL Server}; server = jeff; uid = sa; pwd =; database = test"
End Sub
An array can be defined as an Application object. However, this array can only be saved as an object, and its value cannot be retrieved using Application (0. You can define a temporary array to implement this function. For example:
<%
Dim Array ()
Array = Application ("array ")
For I = 0 to ubound (array)
Response. write Array (I)
Next I
%>
You can also modify the Application object to define a temporary array, assign the Application object to the array, modify the elements of the array, and then assign the array back to the Application object. For example:

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: info-contact@alibabacloud.com 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.