File: MainAds.xml
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>yourImage.gif</ImageUrl>
<NavigateUrl>http://www.java2java.com</NavigateUrl>
<AlternateText>Java2s.com</AlternateText>
<Impressions>1</Impressions>
</Ad>
</Advertisements>
File: Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="AdRotatorTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator id="Ads" runat="server"
Target="_blank" AdvertisementFile="~/MainAds.xml" OnAdCreated="Ads_AdCreated" />
<br />
<br />
<br />
<asp:HyperLink ID="lnkBanner" runat="server">HyperLink</asp:HyperLink></div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class AdRotatorTest : System.Web.UI.Page
{
protected void Ads_AdCreated(object sender, AdCreatedEventArgs e)
{
lnkBanner.NavigateUrl = e.NavigateUrl;
lnkBanner.Text = "Click here for information about our sponsor: ";
lnkBanner.Text += e.AlternateText;
}
}
|