The AdRotator control is used to display a sequence of ad images.
This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad.
The AdvertisementFile property is used to set or return the path to the XML file that contains the advertisement data.
Steps :
1. Select AdRotator control.
2 .Bind xml file as a source to control.
<form runat="server">
<Advertisements>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<asp:AdRotator AdvertisementFile="Ad1.xml"
runat="server" OnAdCreated="change_url"
target="_blank" />
</form>
<p><a href="ad1.xml" target="_blank">View XML file</a></p>
</body>
</html>
This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad.
Element | Description |
---|---|
<ImageUrl> | Optional. The path to the image file |
<NavigateUrl> | Optional. The URL to link to if the user clicks the ad |
<AlternateText> | Optional. An alternate text for the image |
<Keyword> | Optional. A category for the ad |
<Impressions> | Optional. The display rates in percent of the hits |
The AdvertisementFile property is used to set or return the path to the XML file that contains the advertisement data.
Steps :
1. Select AdRotator control.
2 .Bind xml file as a source to control.
Syntax
<asp:AdRotator AdvertisementFile="path" runat="server" />
Example 1 :
<form runat="server">
<asp:AdRotator id="ad1" AdvertisementFile="Ad1.xml" runat="server" />
</form>
XML
<Advertisements>
<Ad>
<ImageUrl>
/banners/w6.gif
</ImageUrl>
<NavigateUrl>
http://www.w3schools.com
</NavigateUrl>
<AlternateText>
W3Schools Main Site
</AlternateText>
<Impressions>
50
</Impressions>
<Keyword>elearning</Keyword>
</Ad>
<Ad>
<ImageUrl>
/banners/rd_xhtml.jpg
</ImageUrl>
<NavigateUrl>
http://www.w3schools.com/xhtml/default.asp
</NavigateUrl>
<AlternateText>
XHTML Tutorial
</AlternateText>
<Impressions>
50
</Impressions>
<Keyword>
XHTML
</Keyword>
</Ad></Advertisements>
Example 2:
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<asp:AdRotator AdvertisementFile="Ad1.xml"
runat="server" OnAdCreated="change_url"
target="_blank" />
</form>
<p><a href="ad1.xml" target="_blank">View XML file</a></p>
</body>
</html>
Xml
This
XML file does not appear to have any style information associated with it. The
document tree is shown below.
<Advertisements>
<Ad>
<ImageUrl>/banners/w6.gif</ImageUrl>
<NavigateUrl>http://www.w3schools.com</NavigateUrl>
<AlternateText>W3Schools
Main Site</AlternateText>
<Impressions>50</Impressions>
<Keyword>elearning</Keyword>
</Ad>
<Ad>
<ImageUrl>/banners/rd_xhtml.jpg</ImageUrl>
<NavigateUrl>http://www.w3schools.com/xhtml/default.asp</NavigateUrl>
<AlternateText>XHTML
Tutorial</AlternateText>
<Impressions>50</Impressions>
<Keyword>XHTML</Keyword>
</Ad>
No comments:
Post a Comment