Export (0) Print
Expand All

AdRotator Web Server Control Overview 

The AdRotator Web server control provides a convenient way to display advertisements (ads) on your ASP.NET Web pages. The control displays a graphic image that you provide — a .gif file or similar image. When users click the ad, they are redirected to a target URL that you have specified. The control automatically reads advertisement information, such as the graphic file name and the target URL, from a list of ads that you provide using a data source, which is usually an XML file or database table.

The AdRotator control selects ads randomly, changing the displayed ad each time the page is refreshed. Ads can be weighted to control the priority level of banners, making it possible to have certain ads display more often than others. You can also write custom logic that cycles through the ads.

Ad information can come from a variety of sources, such as the following:

  • An XML file   You can store ad information in an XML file that contains references to ad banners and their associated properties.

  • Any data source control, such as the SqlDataSource or ObjectDataSource controls   For example, you can store ad information in a database, and can use a SqlDataSource control to retrieve ad information, and then bind the AdRotator control to the data source control.

  • Custom logic   You can create a handler for the AdCreated event and select an ad in the event.

One method of storing ad-banner image locations, URLs for redirection, and associated properties is to put the information in an XML file. By using the XML file format, you can create and maintain a list of advertisements without having to change the code in your application whenever a change is made to an advertisement. For details, see How to: Display Ads From an XML File Using the AdRotator Web Server Control.

Database Schema for Ad Files

Instead of creating an XML file for ad information, you can store ad information in a database table. The table requires a specific schema that the AdRotator control can read. For details, see How to: Display Ads From a Database Using the AdRotator Web Server Control.

In the advertisement file, you can assign categories to ads by using the Keyword attribute and then configuring the AdRotator control to show ads according to the filter criteria that you specify. For example, if a specific ad file contains categories for both banks and hardware stores, you might only want the page to display ads that are related to banks. By setting the AdRotator control's KeywordFilter property to "banks," the hardware store ads will be filtered out.

If a filter is specified, then one of the following two situations can result:

  • If the AdRotator control can find ads with the matching keyword, an ad with the keyword is displayed.

  • If no match for the keyword exists, then the AdRotator control will display a blank image in the browser.

The AdRotator control does not inherently provide a way to gather statistics about which ads users have clicked, how many times an ad has been clicked, and so on. However, because you have control over the URL to which the ad points, you can add tracking logic for the ads to your application. A typical way to do this is to point all ads to a tracking page that first gathers the statistics you want, and then jumps to the ad's destination page.

If the page that contains the AdRotator control is cached, the AdRotator control automatically performs cache substitution to replace the cached ad with a new one whenever the page is retrieved from the cache. For more information, see Dynamically Updating Portions of a Cached Page.

Community Additions

ADD
Show:
© 2014 Microsoft