ASP practice-ASP (1)

Source: Internet
Author: User
ASP counters
The Active Server Pager (Dynamic Server homepage, ASP for short) allows you to conveniently implement page counters by reading and writing Server files and combining the script language (VBscript or Jscript) and html code. The popular ASP textbooks and ASP tutorials on the Internet all talked about the design of ASP counters, but they are too simple, for example, how to separate the counter script from the home page and implement the image counter is not mentioned. The following is an example of my experience in creating an NT web site. I will talk about the design of ASP counters step by step, hoping to inspire ASP beginners and netizens interested in ASP WEB programming.
(1) simple counters
ASP contains five built-in "Active Server Components" (ActiveX Server component), that is, Database Access component (Database Access component) and File Access component (File Access component) ad Rotator component, Brower Capabilities component, and Content Linking component ). The following counter is designed to read and write server files through File Access component. The algorithm is to store the count value in a text (ASCII) file on the server. When the page is accessed, the value is read from the file, displayed to the user, and the value is added to 1, write the added value back to the file.
The ASP statements and descriptions for writing data to a server count file are as follows:
CounFile = Server. MapPath ("file name used to store counter values ")
Server access method MapPath (path) is to convert the path of the file storing the counter value to the physical path
SET FileObject = Server. CreateObject ("Scripting. FileSystemObject ")
How to use CreateObject to define the object FileSystemObject
SET OutStream = Server. CreateTextFile (FileObject, True, False)
The object FileSystemObject provides the CreateTextFile method to generate a text file. The parameter "True" indicates that the original file is overwritten, and "False" indicates that the file is of the ASCII type.
OutStream. WriteLine "data to be written"
OutStream. WriteLine writes a row of data to the file
The ASP syntax for reading data from a server file is as follows:
CounFile = Server. MapPath ("file name used to store counter values ")
SET FileObject = Server. CreateObject ("Scripting. FileSystemObject ")
SET InStream = Server. OpenTextFile (FileObject, 1, false, false)
How does the object FileSystemObject provide OpenTextFile to generate text?
The parameter "True" indicates overwriting the original file, and "False" indicates that the file is of the ASCII type.
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.