Building an In-Text Advertising System Under ASP.NET 3.5 - The General Situation
(Page 3 of 5 )
To gain the aim of embedding an in-text ad inside a special web page, you just need to insert the following code at the far bottom of the page:
<script type ="text/javascript" >var username='222'; </script>
<script type="text/javascript" src="js/getad.js"></script>
Here, the variable "username" is the unique identifier used by the website owner to make ad-related statistics.
Then why select to put the above code at the far bottom of the page? This mainly prevents the possibility of the ad code deferring the loading of the page. Suppose that you put the above code at the top of the page; when the current web page is loading, the first item to load is the ad code, and only when the ad- related code is loaded can the page be rendered. Obviously, this should be avoided, or it may make the page seem slow to load and even "dead," which is of course converse of the original idea of the website owner. Thus, it's highly suggested that the ad code be put at the far bottom of the page, which will not tamper with the normal loading and rendering of the page even if the ad code cannot be shown.
Figure 3 indicates one of the run time snapshots of the in-text advertising application in use.
Figure 3-the in-text advertising application in use

Next, let's start to resolve the architecture of the application system.
System Architecture
In this case, for readers to gain a clearer insight into the system, we'll first illustrate the related architecture diagram, as shown in Figure 4 below.
Figure 4-the rough architecture of the system

As you've seen, the in-text ad application is a typical three-tier system. Moreover, it's a client-centric application with lots of client-side JavaScript programming.
Next, it's also necessary to look at the folder structure of the website, as shown in Figure 5 below.
Figure 5-the file and folder structure of the website

For more details about the roles and functions of each of the files in Figure 5, please refer to the Table 1 listed below.
Table 1-the detailed explanation of the system files
File Name | Note |
App_DataAD.mdf | The database of the system |
App_Codesql.cs | Encapsulates the database-related operations |
App_Codetools.cs | Encapsulates an encrypting method |
App_CodevalidateCode.cs | The class that generates the verifying code-related picture, which provides two methods to generate the random number and verifying code |
Jsad.js | The core code of the in-text system-generates the in-text ads and renders them |
Jsxmlhttp.js | Encapsulates the AJAX related client-side manipulations |
Jsgetad.js | Encapsulates the ad code for the website host to invoke conveniently |
Ad.ashx | The handler that acquires the specified keyword-related ad contents |
adArray.ashx | The handler that acquires the keyword array |
Admin1.aspx | Manages the ad keywords |
Admin2.aspx | Manages the ad keywords-related contents |
Gif.aspx | The page responsible for generating verifying code |
Login.aspx | The login page for the website owner and the administrator |
Redirect.aspx | The navigating page relating the ad contents, used to record ad data |
siteUser.aspx | The user center of the website owner related page |
Test.aspx | The illustrative page on which to place ad code |
Next, we'll shift our attention to the database design.
Next: Database Design >>
More ASP.NET Articles
More By Xianzhong Zhu