In this article, we'll look at two examples that use AdRotator server controls to display ads on one page.
There are several steps to using the AdRotator server control:
First step
Create an XML file that contains the details of the advertisement, such as Art008_ads.xml, which contains the following elements:
imageurl-contains the URL that will be displayed, either an absolute path or a relative path relative to the page that displays the advertisement.
navigateurl-contains the URL of the target Web site. (Note: Before the beta version, this element was called TargetUrl and now changed).
alternatetext-contains some text that is displayed as a hint when the mouse moves over the image. In other words, this is the text of the ALT element in the advertisement image.
keyword-This optional element contains the category that the advertisement belongs to. This allows all categories of ads to be in the same XML, and then filters the ads on a given page using the KeywordFilter property in the AdRotator control.
impressions-points to the relative cost of advertising.
One thing that is particularly noteworthy when creating an ad file is that it is case-sensitive. Therefore, the included elements should be spelled correctly, for example: you should use <Ad> instead of <ad>.
With the above details, we will create the ad XML file. The following XML file contains information that displays two ad banners:
<Advertisements>
<Ad>
<ImageUrl>/articles/demo/art008_demo1.gif</ImageUrl>
<NavigateUrl>http://www.dotnet101.com</NavigateUrl>
<alternatetext>go to. net101--Test 1</alternatetext>
<Keyword>Category1</Keyword>
<Impressions>10</Impressions>
</Ad>
<Ad>
<ImageUrl>/articles/demo/art008_demo2.gif</ImageUrl>
<NavigateUrl>http://www.dotnet101.com</NavigateUrl>
<alternatetext>go to. net101--Test 2</alternatetext>
<Keyword>Category1</Keyword>
<Impressions>10</Impressions>
</Ad>
<Ad>
<ImageUrl>/articles/demo/art008_demo3.gif</ImageUrl>
<NavigateUrl>http://www.dotnet101.com</NavigateUrl>
<alternatetext>go to. net101--Test 3</alternatetext>
<Keyword>Category2</Keyword>
<Impressions>10</Impressions>
</Ad>
</Advertisements>