This article introduces ASP. NET AdRotator control, many people may not understand ASP. the AdRotator control in NET does not matter. After reading this article, you will certainly have a lot of GAINS. I hope this article will teach you more.
The AdRodator control is used to generate random ad elements on the page and obtain or set the path of an 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 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.
This solves the problem of using the AdRotator control in ASP. NET.
- How does ASP. NET Eval bind data?
- Example: ASP. NET Eval: How to Write database binding expressions
- A special method for verifying ASP. net mvc data
- ASP. NET close Page Server dialog layer clear
- Simple Analysis of ASP. net mvc Control Project Development