65.9K
CodeProject 正在变化。 阅读更多。
Home

带 AJAX 的 AdRotator

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2013 年 10 月 11 日

CPOL
viewsIcon

7370

首先创建一个 XML 文件,路径为 App_Data/Advertisements.xml    

首先创建一个 XML 文件,路径为 App_Data/Advertisements.xml

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
 <Ad>
    <ImageUrl>~/images/dnc.jpg</ImageUrl>
    <NavigateUrl>http://www.dotnetcurry.com</NavigateUrl>
    <AlternateText>DotNetCurry 首页</AlternateText>
    <Impressions>40</Impressions>
    <Keyword>small</Keyword>
 </Ad>
 <Ad>
    <ImageUrl>~/images/ssc.jpg</ImageUrl>
    <NavigateUrl>http://www.sqlservercurry.com</NavigateUrl>
    <AlternateText>SQL Server Curry 首页</AlternateText>
    <Impressions>20</Impressions>
    <Keyword>small</Keyword>
 </Ad>
 <Ad>
    <ImageUrl>~/images/writeforus.jpg</ImageUrl>
    <Width>300</Width>
    <Height>50</Height>
    <NavigateUrl>http://www.dotnetcurry.com/writeforus.aspx</NavigateUrl>
    <AlternateText>dotnetcurry.com 为我们写作</AlternateText>
    <Impressions>40</Impressions>
    <Keyword>small</Keyword>
 </Ad>
</Advertisements>

 

将 ASPX 代码编写如下
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" Interval="2000" runat="server" />

    <asp:UpdatePanel ID="up1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
            <asp:AdRotator
            id="AdRotator1"
            AdvertisementFile="~/App_Data/Advertisements.xml"
            KeywordFilter="small"
            Runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel> 
</div>
</form>

 

 

Nimish Garg
软件开发人员
Indiamart Intermesh Limited, Noida

获取免费的 ASP.NET 和 Oracle 代码片段
关注:http://nimishgarg.blogspot.com

© . All rights reserved.