Controls You Can Use on Web Forms ASP.NET Standard Controls AdRotator Control
Advertisements on Web pages typically take the form of ad banners — .gif files or similar images — that when clicked redirect the user to the advertisers' Web pages. In order to generate ads on your Web page you will need the image files and accompanying URLs.
Using the AdRotator Web server control you can display and cycle through a series of ad banners. The AdRotator automates the cycling process, 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.
Use the AdRotator control to retrieve and display ads with one of two methods:
- Create an XML file containing references to ad banners and their associated properties.
- Write your own logic to select an ad banner in the AdCreated 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 when a change is made to an advertisement.
The XML file can be created using the Ad Rotator Schedule File template in the XML designer.
In the XML file you can assign categories to ads and then configure the AdRotator control to show ads according to filter criteria you specify.
For example, if a specific AdvertisementFile contains categories for both banks and hardware stores you may only want the page to display ads related to banks. By setting the KeywordFilter property to "banks" the hardware store ads will be filtered out.
If a filter is specified, then one of two situations can result:
- If the ad source is an XML advertisement file, then ads with a matching keyword will be selected.
- If the ad source is an XML advertisement file, but no match exists in the ad file, then the AdRotator will display a blank image and a trace warning will be generated.
Within the AdCreated event you can also write logic that records information about the banner being displayed, such as such as the number of times the users clicks it. In the event handler, change the NavigateUrl property to navigate to a redirection page that you will add to your application. This new page will log the information you want to keep track of. Pass the URL of the page you want the user to eventually be directed to and any other information you wish to log as a parameter. The redirection page will take the destination URL parameter and navigate to it once the information has been processed.
Adding AdRotator Controls to a Web Forms Page