The AdRotator control is a server control used to generate random ad elements on the page and obtain or set the path of the XML file containing ad information through the AdvertisementFile attribute. The xml file I wrote during the test is as follows:
- //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>
-
The code of the page body is as follows:
- < form ID="form1" runat="server">
- < asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="Ads.xml" Target="_blank"/>< br />
- < /form>
The following error message about the AdRotator control is displayed during running:
The AdRotator AdRotator1 cocould not find the AdvertisementFile or the file is invalid.
No problem was found after checking it several times. Later, I found that the Advertisements in Ads. xml is incorrectly written as Adertisements, but the system will not tell you exactly what went wrong during the runtime. To solve this problem, first check whether words are spelled incorrectly. Then, check whether words are case sensitive in xml. For example
- < NavigateUrl>http://hi.baidu.com/hoyah< /NavigateUrl>
The error code is
- < Navigateurl>http://hi.baidu.com/hoyah< /Navigateurl>
The error is the same as the word above. In addition, the image path and AdvertisementFile point to the xml file path, which are particularly error-prone.
The above are the most common problems with using the AdRotator control in asp.net.
- Application of session storage mode in ASP. NET
- Set of methods for uploading and downloading files in ASP. NET
- Introduction to cookie read/write methods in ASP. NET
- Javascript operations in ASP. NET
- Introduction and implementation of Single Sign-On in ASP. NET2.0