Introduction:
Use the AdRotator control to display a randomly selected advertisement banner on the Web page. The displayed advertisement changes whenever the page refreshes.
Advertisement information is stored in a separate XML file. The XML file allows you to maintain a list of advertisements and their associated attributes. Attributes include the path to an image to display, the URL to link to when the control is clicked, the alternate text to display when the image is not available, a keyword, and the frequency of the advertisement. Information in this file is not validated by the AdRotator control. To prevent ads from executing malicious scripts, you should always check the data before releasing it, or accept ad information only from trusted sources.
.aspx Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="Adrotator1" Target="_newwindow" AdvertisementFile="~/XMLFiles/Add.xml" runat="server" OnAdCreated="AdCreated_Event" />
</div>
</form>
</body>
</html>
.CS Page
public void AdCreated_Event(Object sender, AdCreatedEventArgs e)
{
e.NavigateUrl = "http://www.google.co.in";
}
Add.Xml
public void AdCreated_Event(Object sender, AdCreatedEventArgs e)
{
e.NavigateUrl = "http://www.google.co.in";
}
Add.Xml
<Advertisements>
<Ad>
<ImageUrl>../Images/1.jpg</ImageUrl>
<NavigateUrl>http://www.google.co.in</NavigateUrl>
<AlternaeText>Google Site</AlternaeText>
<Impressions>2</Impressions>
<keyword>IstAdd</keyword>
<Caption>Google</Caption>
</Ad>
</Advertisements>
<Ad>
<ImageUrl>../Images/1.jpg</ImageUrl>
<NavigateUrl>http://www.google.co.in</NavigateUrl>
<AlternaeText>Google Site</AlternaeText>
<Impressions>2</Impressions>
<keyword>IstAdd</keyword>
<Caption>Google</Caption>
</Ad>
</Advertisements>
No comments:
Post a Comment