When you write a server-side application with ASP, you must rely on the function of the ActiveX component to power the web application, such as: You need to connect the database, online operation of the database, etc., this article will begin to introduce ASP ActiveX in this article. The method of use of components.
From today we will officially learn the essence of ASP --activeX components. In fact, when you write a server-side application with an ASP, you must rely on the functionality of the ActiveX component to power the web application, such as: You need to connect the database, perform online operations on the database or operate on the file system on the web server, Or you need a web ad exchange program, all this must be done by calling the ASP built-in ActiveX component or yourself to write the required components.
So what exactly is the ActiveX component? How is it working? In fact, the ActiveX component is a file that exists on the web server. This file contains code that performs an item or a set of tasks. Components can perform public tasks, so you don't have to create code that executes these tasks. For example, the stock market receipt machine assembly can display the latest stock quotes on the web page. When you are installed on the web server, you can directly use several common components that own, such as the Database Access component. Of course, you can also get optional components from third-party developers, or write your own components. You can use the component as a script and a web application-based basic construction block, just know how to access the components provided, even if you are a new hand to write a script, you can write an ASP program without understanding the component operation. All in all, ActiveX components allow you to write a powerful web server-side script without learning complex programming. If you are a developer of a bit web application, you can write components such as C, C , Java or Visual Basic using any language that supports component object model (COM). If you are familiar with COM programming, the ActiveX component is an Automation server. But to run on the web server, the ActiveX component does not have graphical user interface elements, such as the MSGBox function of Visual Basic. Components can be reused. Once the component is installed on the web server, you can call the component from the ASP script, the ISAPI application, other components on the server or program written by another COM-compatible language.
So how should we call components in ASP? As previously mentioned, the component is an executable code included in a dynamic link library (.dll) or executable file (.exe). Components can provide one or more objects and methods and properties of objects. To use the object provided by the component, we first create an instance of an object and assign a variable name of this new instance. The instance of the object can be created using the Server.createObject method for the ASP. Next, the variable allocation instruction using the scripting language is named. When you create an object instance, you must provide the registration name "ProgID" of the instance. As you want to create an instance of an AD Rotator object:
<% Set myads = server.createObject ("mswc.adrotator")%>
We must use the ASP's Server.createObject method to create an object instance, whether the ASP cannot track the use of objects in the scripting language.
You can also create an object instance using the HTML
The commonly used components that ASP can be installed will be listed below.
Ad Rotator Creates an ADROTATOR object that can be automatically rotated on the same page on the same page as specified. Browser Capabilities Create a browsertype object that determines the performance, type, and version of each browser that accesss the Web site. Database Access provides access to the database with ActiveX Data Objects (ADO). Content Linking Creates a NEXTLINK object that can generate a list of web page contents and connect each page. The File Access component provides the input and output of the file. The Collaboration Data Objects for NTS components can add send and receive email features on the web page on the web page. This component applies only to Internet Information Server for Windows NT® Server. MyInfo creates a MyInfo object that tracks personal information, such as site administrators' name, address, and display selection. COUNTERS Creates a Counters object that can be created, saved, increased or retrieves any number of independent counters. Content Rotator automatically flips the HTML content string on the web home page. Page Counter Record and Displays the number of times the web page is opened.
Now the web ad is almost full of the entire network, so how do you build an advertising system that meets the standard features of your own website? The answer is to use the ASP Ad Rotator component! It allows new ads to display on the page at each access ASP page, and provides a strong feature, such as the ability to rotate the advertising image on the page, track specific ads The ability to display the number of times and the ability to track the number of clients on the advertisement. The operation of the AD Rotator component is done by reading the AD Rotator program file, which includes information related to the location of the image file to be displayed and the different properties of each image, below is a standard Ad Rotator program file. :
--- ADROT.TXT ---
Redirect /scripts/adredir.asp
Width 440
HEIGHT 60
Border 1
*
ADS / HomePage / Chinabyte.gif
http://www.chinabyte.com/
Check Out the it site
2
ADS / homepage / gamichlg.gif
-
Sponsored by flyteworks
3
ADS / HomePage / Asp.gif
http: // www.aspallian.com/
Good ASP Site on Net
3
ADS / HomePage / Spranklg.gif
http://www.clocktower.com/
The # 1 sports site on the net
2
The first four lines of this code contain global settings for ads. The Redirect line indicates the URL that the ad will become its thermal connection. Note that this is not specified for the advertisement itself, but the URL of the intermediate page will be called so that we can track the number of times the ads can be clicked by this intermediate page. The Redirect URL will call with the query string containing two parameters: the URL of the specific ad homepage and the URL of the image file. The remaining three lines of the asterisk briefly explain how to display ads. The front two lines specify the width and height of the advertisement on the web page in pixels, the default value is 440 and 60 pixels. The latter line is the same as the border width of the advertisement-wide hyperlink by pixels, and the default value is 1 pixel. If this parameter is set to 0, there is no border. The rows under the asterisk describe the details of each ad at a single unit. In this case, there are 16 lines, and four ads are described. Each advertisement describes the URL of the image file, the home page URL of the ad (If the advertiser does not have the home page, please write a single character "-" in this line, indicating that the advertisement does not link) and the image of the image and the specified This page alternates the value of the frequency of the display with other pages.
The image is a hot connection to the page, which sets two values in the query string, url = / scripts / adredir.asp, and image = / ads / homepage / asp.gif. To determine the frequency of the ad display, you can add all the values of all ads in the plan file. In this case, the total number is 10, then aspallian's advertising weight is 3, which means that the Adrotator component is 10 times, it shows 3 times.
The redirect file is the file created by the user. It typically contains scripts used to parse query strings sent by the ADROTATOR object and redirect the user to the URL associated with the ad hit the user. The user can also include the script in the reset file to count the number of users of a particular advertisement and save this information to a file on the server. Increasing the counter and redirect users are implemented by the following two lines ASP scripts:
<%
Counter.Increment (Request.QueryString ("URL"))
Response.Redirect (Request.QueryString ("URL"))
%>
Now let's take a look at how the AD Rotator component is used in the page, you must first instantiate the AD Rotator object using the Server.createObject method. The Progid property of the AD Rotator component is Mswc.Adrotator. The complete code is as follows: <% set ad = server.createObject ("mswc.adrotator")%> <% = ad.getadvertisement ("/ ads / adrot.txt")%>
The only way AD Rotator component support is getadvertisement, which has only one parameter: The name of the Adrotator plan file. Note that the path to the file is the relative path from the current virtual directory, and the physical path is not allowed. The Getadvertisement method gets the detailed description of the next planned advertisement from the Rotator program file and formatted it into an HTML format. The following HTML is generated by the getadvertisement method and is added to the output of the web page to display the next advertisement in the Rotator program file.