Adrotator.aspx, create a AdRotator server control on the asp.net page to connect the ad XML file to this control. Use the following server control tags to complete the
Copy Code code as follows:
<asp:adrotator id= "AdRotator1" runat= "Server" advertisementfile= "~/xmlfile.xml"/>
Code to generate Ads
Copy Code code as follows:
AdRotator.aspx.cs
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
public partial class MyTest_advertisement:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
}
protected void ad_created (object sender, AdCreatedEventArgs e)
{
if ((string) e.adproperties["Animal"]!= "")
Label1.Text = (string) e.adproperties["Aniaml"];
Else
Label1.Text = "N.a."
}
}
XML Document Format
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<Advertisements>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
<Ad>
<ImageUrl> picture Path (local) </ImageUrl>
<NavigateUrl> Picture Connection </NavigateUrl>
<AlternateText> tips When you put your mouse on it </AlternateText>
<Keyword> keywords </Keyword>
<Impressions> Priority </Impressions>
</Ad>
</Advertisements>
Note XML
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 ads