Combining objects and components in ASP

Source: Internet
Author: User
Tags contains count execution time limit
An object is typically something that has methods, attributes, or collections, and the object method determines what we can do with the object. (Remember the Response object's write () method), the object's properties can be read to understand object state or set object state. The collection of objects is made up of a pair of different pairs of keys and values that are related to the object.

For a daily example, the book "Step to Branch ASP Tutorial" is an object that contains methods that determine how you can handle it, for example, to read it, to send people as gifts, as a knock on the door, or even to shatter, as long as you want. The properties of the object, the number of pages in the book, the author or something. Finally, the collection of objects contains many pairs of keys and values: The page number is the key, and the value is the content of the page that corresponds to the page number.

An ActiveX component is very similar to an Active Server Pages inline object, but when you use Active Server Pages, there is a significant difference between the two, first of all, a component may contain more than one object, and secondly, before you use the component, You will explicitly create an instance.

Both VBScript and JScript include objects, such as using VBScript and JScript, and you can go to the processing Dictionary object. Dictionary is not a formal part of active Server page. But you can use the active Server pages script to build it, which is an example of using VBScript:


<%
Set mydict=server.createobject ("Scripting.Dictionary")

Mydict.add "e-commerce", "Http://207.153.210.86/intro"

Mydict.add "BBS", "Http://www.magicw3.com/bbs"

Mydict.add "AD League", "Http://www.magicw3.com/banner"
%>

I have <%=MyDict.count%> records in my dictionary.


The first of these records is <%=mydict.item ("e-commerce")%>.

When the script executes, an instance of the Dictionary object is generated, and then three keys and corresponding values are added to the Dictionary object, and finally, the two properties of the Dictionary object are displayed.

The first scripting statement in the example is a common way to build a new instance of ActiveX objects using active Server pages. Server.creatobject is the creation of an object instance. In this example, the variable mydict points to a Dictionary object instance.

When an instance of an object is established, you can call its method, for example, by using the Add method of the Dictionary object to add a new record to the dictionary. For example, use the Add method pair to add "e-commerce" and the corresponding value "Http://207.153.210.86/intro".

When an instance of an object is established, you can also enter the properties that handle it, where the Count property is used to count the number of records in the dictionary. The Item property is used to read the corresponding value based on the corresponding key.

Finally, you can eliminate the instance of this object after you have finished processing it. Of course, this object instance is automatically eliminated after the server finishes the process in this Active Server Pages, so you don't have to deal with this process yourself. However, if you need to, you can still use a particular variable, such as the current mydict, to point to a new value or nothing to eliminate the instance. such as this

<% Set mydict=nothing%>

Although the Dictionary object is not a formal part of Active Server Pages, this example can indicate how to use the Active Server Pages object, and you can call the Server.creatobject () method to produce an instance of an object. After you have created a new object, you can call its method and read its properties.

Active Server Pages Object

You have contacted an example of an inline object-response object. You can already use the response object to output an expression to the browser. However, response objects also have a significant number of other important attributes, collections, and methods.

The use of each inline object is described in detail in the following sections. Here's a quick view of each inline:

Application object: The Application object is used to store information shared by all users in an application. For example, you can use the Application object to pass information between different users of your site.

Request object: The Request object can be used to access all information from the browser to the server, and you can use the request object to accept the user's information in the form in the HTML home page.

Response object: The Response object is used to send information back to the browser. You can use the response object to output your scripting language results to your browser.

Server object: The server object provides application functions that you use many server-side. For example, you can use the server object to control how long your scripting language runs before it exceeds the time limit. You can also use the server object to create instances of other objects.

Session object: Sessions object is used to store information about the duration of a regular user's stay, and you can store the duration of a user's visit to your site with a sessional object.

ObjectContext object: ObjectContext object can be used to control the execution of active Server pages. This process of execution is managed by Microsoft Transaction Server (MTS).

Inline objects are different from normal objects. You don't need to first create an instance of an inline object while you're using the script. All of the methods, collections, and properties of an inline object in an entire Web site application are automatically accessible.

Active Server Pages Component

Like the inline object discussed above, the Active Server pages component can be used to expand the functionality of your scripts, and the components that are different from inline are often used to implement those specific tasks. The following list shows some of the components that are integrated in active Server pages.

Ad Rotator Component: The Ad Rotator component is used to display an advertisement icon on the home page. You can use this component to define how often different advertising icons display the transformation.

Browser Capabilities components: The Browser Capabilities component can display different home pages based on the performance of different browsers. For example, you can use the display of a single screen or depending on the browser to adapt to the split-screen mode. Content Linking components: example with content linking components you can connect a significant number of home pages so you can make it easier to navigate the web. For example, you can use this component to display an online tutorial.

Counters component: The counters component can be used to track the number of visitors to the site, and you can use this component to add a hit counter to the home page.

Permission Checker components: Permission Checker components can be used to verify that only authorized users can access certain joins. You can use this component to create an administrator's maintenance home page.

ActiveX Data object: The ActiveX Data Object (ADO) provides the means by which you can store data from a database system such as SQL Server. This object is very important, and for this reason, the object will be introduced separately after all the objects have been discussed.



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: 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.