AdRotator控件应用示例
这个控件很简单,使用的是XML文件作为数据源。
aspx文件源码
1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdRotatorControl.aspx.cs" Inherits="AdRotatorControl" %>
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>广告控件应用示例</title>
8</head>
9<body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:Panel ID="adPanel" runat="server" Height="50px" Width="125px">
13 <asp:AdRotator ID="MyAdRotator" runat="server" AdvertisementFile="~/App_Data/Ad.xml"
14 Height="60px" Width="60px" />
15 </asp:Panel>
16
17 </div>
18 </form>
19</body>
20</html>
1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdRotatorControl.aspx.cs" Inherits="AdRotatorControl" %>
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>广告控件应用示例</title>
8</head>
9<body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:Panel ID="adPanel" runat="server" Height="50px" Width="125px">
13 <asp:AdRotator ID="MyAdRotator" runat="server" AdvertisementFile="~/App_Data/Ad.xml"
14 Height="60px" Width="60px" />
15 </asp:Panel>
16
17 </div>
18 </form>
19</body>
20</html>
xml文件
1<?xml version="1.0"?>
2<Advertisements>
3 <Ad>
4 <ImageUrl>~/sohu.gif</ImageUrl>
5 <NavigateUrl>http://www.sohu.com</NavigateUrl>
6 <AlternateText>sohu网站</AlternateText>
7 <KeywordFilter>software</KeywordFilter>
8 <Impressions>80</Impressions>
9 </Ad>
10 <Ad>
11 <ImageUrl>~/tom.gif</ImageUrl>
12 <NavigateUrl>http://www.tom.com</NavigateUrl>
13 <AlternateText>tom网站</AlternateText>
14 <KeywordFilter>software</KeywordFilter>
15 <Impressions>80</Impressions>
16 </Ad>
17</Advertisements>
1<?xml version="1.0"?>
2<Advertisements>
3 <Ad>
4 <ImageUrl>~/sohu.gif</ImageUrl>
5 <NavigateUrl>http://www.sohu.com</NavigateUrl>
6 <AlternateText>sohu网站</AlternateText>
7 <KeywordFilter>software</KeywordFilter>
8 <Impressions>80</Impressions>
9 </Ad>
10 <Ad>
11 <ImageUrl>~/tom.gif</ImageUrl>
12 <NavigateUrl>http://www.tom.com</NavigateUrl>
13 <AlternateText>tom网站</AlternateText>
14 <KeywordFilter>software</KeywordFilter>
15 <Impressions>80</Impressions>
16 </Ad>
17</Advertisements>