The advertisement business is one of the main revenue of the network. Through this example, readers will understand the main functions and basic principles of dynamic advertisements.
Figure 95-1 shows the page returned after the user logs on. This page is used to enter the advertisement image information and upload the advertisement image to the server. Figure 95-2 shows the actual display of the ad image, which is displayed randomly based on the display probability of the ad image.
The idea is to upload advertisement images to the server through the "FileUpload" server control in ASP. NET2.0, and input advertisement image information through the "update record" server behavior. Using the "Rnd ()" random function and dataset, you can achieve random display of ad images.
Procedure
Step 1. Set the application environment
(1) copy the content of instance 95 on the CD. Copy all the files in the "CD source file instance 95" directory to the "C: Inetpubwwwroot" directory. Set the default value in the IIS serverWebsiteThe main directory of is "C: Inetpubwwwrootadweb" (refer to related methods in instance 1 ). Click "adweb" to create a new website in Dreamweaver. The website directory is "C: Inetpubwwwrootadweb". (for how to create a website, refer to instance 2 ).
(2) data structure of the "AD" table. Run Access and open "C: InetpubwwwrootadwebdataAD. mdb". You can see that the database "AD. mdb" contains "AD" and "aduser" data tables. The "AD" table is used to store AD images. The data structure of this table is shown in Figure 95-3. The "User" table is used to store the User's login name and login password. The data structure of this table is shown in Figure 95-4.
(3) create a database link "ADconn" and link the database "C: Inetpubwwwrootadweb dataAD. mdb". For details, refer to instance 75.
Step 2. Logon page
(1) "index. aspx" page structure. Open index. aspx, as shown in Figure 95-5. The ID of the text box corresponding to "user name" is "usename"; the ID of the text box corresponding to "login password" is "pass "; the ID of the text box corresponding to "input additional code" is "valicode ". The ID of the Image button is "Image", and the Image URL is "numdraw. aspx". This file is provided in the original material. For details about the creation and function of this file, refer to instance 81. The logon button is a form button with the ID "Submit" and the action is "Submit Form ".
<