The asp.net| control uses the AdRotator control in ASP.net
Ads in asp.net can be displayed at any time by using the AdRotator server control that ASP.net carries. In this article, we'll look at two examples that use this control 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:
Http://www.dotnet101.com/articles/demo/art008_demo1.aspx here for a demo.
The AdvertisementFile attribute indicates that the advertisement file must refer to the AdRotator control in order to display the image. Because the KeywordFilter property is not set, you will see all three ad images appear randomly when you refresh the page.
To change the appearance of the ad image on the page, you can also set other properties for the AdRotator control. Here are some of the important properties:
AdvertisementFile: XML containing advertising information
BorderColor: Sets the border color for the advertisement, such as bordercolor= "#000000" to set the boundary to black
BorderWidth: Boundary width, Unit is pixel, such as borderwidth= "1"
CssClass: A font class from a CSS file or inline STYLE element, such as cssclass= "Clsads"
Height: Advertisement image altitude, Unit is pixel
KeywordFilter: Filter The advertising category, as seen in the example above
Target: The destination window for the URL when clicking on the ad. such as target= "_new", every time the ad image is clicked will produce a new window. "_top" is the default value
Width: The breadth of the advertising image, in pixels
The KeywordFilter property of a AdRotator control can filter a specific category of advertisements. In the following example, you will see only the first two images belonging to the "Category1". The example also combines some of the properties defined in the table:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.