新聞中心
本文向大家介紹ASP.NET中的AdRotator控件,可能好多人還不了解ASP.NET中的AdRotator控件,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會(huì)你更多東西。

AdRodator控件用來在頁(yè)面上生成隨機(jī)廣告性質(zhì)的元素,并通過AdvertisementFile屬性獲取或設(shè)置包含廣告信息的XML文件的路徑。以下是我測(cè)試時(shí)寫的xml文件:
- //File name:Ads.xml
- //Author:Hoyah
- < ?xml version="1.0" encoding="utf-8" ?>
- < Adertisements>
- < Ad>
- < ImageUrl>images/5.jpg< /ImageUrl>
- < NavigateUrl>http://hi.baidu.com/hoyah< /NavigateUrl>
- < AlternateText>Hoyah's Space< /AlternateText>
- < Impressions>200< /Impressions>
- < Keyword>Hoyah< /Keyword>
- < /Ad>
- < Ad>
- < ImageUrl>images/1.jpg< /ImageUrl>
- < NavigateUrl>http://g.cn< /NavigateUrl>
- < AlternateText>Google< /AlternateText>
- < Impressions>500< /Impressions>
- < Keyword>Google< /Keyword>
- < /Ad>
- < /Adertisements>
頁(yè)面body部分代碼如下:
- < form ID="form1" runat="server">
- < asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="Ads.xml" Target="_blank"/>< br />
- < /form>
運(yùn)行時(shí)出現(xiàn)以下錯(cuò)誤信息:
The AdRotator AdRotator1 could not find the AdvertisementFile or the file is invalid.
檢查了好幾遍也沒發(fā)現(xiàn)問題。后來仔細(xì)一看發(fā)現(xiàn)Ads.xml中Advertisements錯(cuò)寫為了Adertisements,而在運(yùn)行時(shí)系統(tǒng)不會(huì)具體告訴你哪兒出了錯(cuò)。所以遇到這樣的問題,首先要檢查有沒有單詞拼錯(cuò);再看看大小寫問題,因?yàn)閤ml中是嚴(yán)格區(qū)分大小寫的。比如,若把上面Ads.xml中的
- < NavigateUrl>http://hi.baidu.com/hoyah< /NavigateUrl>
錯(cuò)寫為
- < Navigateurl>http://hi.baidu.com/hoyah< /Navigateurl>
就會(huì)出現(xiàn)跟上面寫錯(cuò)單詞一樣的報(bào)錯(cuò)。另外還要注意圖片路徑及AdvertisementFile所指向xml文件的路徑,這些都是特別容易出錯(cuò)的地方。
這樣就解決了ASP.NET中使用AdRotator控件的問題。
文章標(biāo)題:ASP.NET中的AdRotator控件
標(biāo)題鏈接:http://m.fisionsoft.com.cn/article/cdesgpj.html


咨詢
建站咨詢
