2012-09-06 28 views
1

我試圖使用AdRotator控件進行定時以獲得幻燈片放映的圖像。對於這點我嘗試這樣的事情 XMLFile1文件在asp.net中的AdRotator控件

<?xml version="1.0" encoding="utf-8" ?> 
    <Advertisements> 
     <Ad> 
     <ImageUrl>~\Images\1.jpg</ImageUrl> 
     <NavigateUrl>http://www.google.com</NavigateUrl> 
     <AlternateText>AdRotator Control sample ads</AlternateText> 
     <Impressions>20</Impressions> 
     <Keyword>Asp.Net</Keyword> 
     </Ad> 

     <Ad> 
     <ImageUrl>~\Images\2.jpg</ImageUrl> 
     <NavigateUrl>http://www.gmail.com</NavigateUrl> 
     <AlternateText>AdRotator Control sample ads</AlternateText> 
     <Impressions>30</Impressions> 
     <Keyword>Asp.Net</Keyword> 
     </Ad> 
    </Advertisements> 

WebForm1.aspx的

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TrialVersion.WebForm1" %> 

    <!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></title> 
    </head> 
    <body> 
     <form id="form1" runat="server"> 
     <div> 
     <asp:ScriptManager ID="scriptmanager1" runat="server"> 
     </asp:ScriptManager> 
     <asp:Timer ID="Timer1" runat="server" Interval="500"></asp:Timer> 
     <asp:UpdatePanel ID="upanel" runat="server" UpdateMode="Conditional" 
     Visible="False"> 
     <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> 
     </Triggers> 
     <ContentTemplate> 
     <asp:AdRotator id="adrotator" runat="server" AdvertisementFile="~/XMLFile1.xml" KeywordFilter="Asp.Net"/> 
     </ContentTemplate> 
     </asp:UpdatePanel> 

     </div> 
     </form> 
    </body> 
    </html> 

在建立這個程序,它給了我一個空白頁,並沒有顯示的圖像。爲什麼這樣。

回答

1

你可以檢查刪除頂部的所有不必要的代碼(ScriptManager,Timer和更新面板)。所以你將能夠找出問題。我認爲問題不在於您的廣告輪播,而是您的定時器和更新面板。

+0

號它不是給我一個錯誤。請回復 – Aada

+0

你得到的錯誤是什麼? – Geethanga

+0

但我需要使用定時器..的圖像改變在一個正常的時間 – Aada

1

這是因爲你在UpdatePanel中有Visible =「False」。拿出來,圖像應該顯示出來。

2

而不是給這個

<ImageUrl>~\Images\1.jpg</ImageUrl> 

你只要給這樣

<ImageUrl>Images\1.jpg</ImageUrl> 

希望它會工作