ASP 3.0 advanced programming (19th)

Source: Internet
Author: User
5.3.2 Dictionary object example
This book provides a series of sample files that can be used to test various attributes of the script runtime library.
The default page of the code in this chapter provides a series of examples of VBScript that can be used. Some examples are equally valid for JScript. These examples are stored in the corresponding sub-directories under the Chapter05 Directory. The displayed interface is shown in Figure 5-2:
Figure 5-2 ASP script runtime object example page
To view the running of a Dictionary object, click the first link on the menu page to open the page named show_dictionary.asp. This page displays the contents of our Dictionary object, allowing you to test its attributes and methods. The screen is shown in Figure 5-3:
Figure 5-3 Attributes and methods of a Dictionary object
1. global. asa file of Dictionary
One of the files provided on the example page of the Dictionary object is global. asa. It creates and pre-fills a session-layer scope Dictionary object, so its content will not be lost between page requests. Generally (considering scalability), this is not an ideal practice. In this example, we can see the effects of the attributes and methods of the Dictionary.
If you download and install the sample on your server, you must create a virtual application based on the global. asa file. Or add the content to the global. asa file in the root folder of the default site. Chapter 1 describes how to use a wizard to create a virtual application. However, in this example, the easiest way to Create a virtual application is to right-click the dictionary subfolder in the Chapter05 sample folder and click Create in the Home Directory tab of the Properties dialog box, as shown in Figure 5-4:
Figure 5-4 create a virtual application
In this global. asa file, the code uses the <OBJECT> element to create a session-layer Scripting. Dictionary OBJECT instance. Then, in the Session_onStart event handler, place a series of values into the Dictionary using the Add method, and specify the reference to the Dictionary object to the ASP session variable MyDictionary:
<Object id = "objBookList" RUNAT = "SERVER" SCOPE = "SESSION"
PROGID = "Scripting. Dictionary">
</OBJECT>
<Script language = "VBScript" RUNAT = "SERVER">
Sub Session_onStart ()
ObjBookList. Add "2610", "Professional Active Server Pages 3.0"
ObjBookList. Add "1274", "Instant JavaScript"
ObjBookList. Add "2882", "Beginning ASP Components"
ObjBookList. Add "1797", "Professional ASP Techniques"
ObjBookList. Add "1835", "AD0 2.0 Programmer's Reference"

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.