ARTICLE

AdRotator Standard Control

Posted by Munir Shaikh Articles | Visual Basic 2010 August 22, 2007
This article will help programmer, developer to overcome the problem as: "The AdRotator adRtrCtrl/adRotator1 could not find the AdvertisementFile or the file is invalid".
Download Files:
 
Reader Level:

Recently I was working on AdRotator controll in Asp.Net 2.0, at one stage while adding Ads.xml file.

I notice following error:

 

Error:

The AdRotator adRtrCtrl/adRotator1 could not find the AdvertisementFile or the file is invalid.

 

Possible causes:

 

Check XML file if it is in well format. Check <NavigateUrl> tag, if it is of the form http://www.csharpcorner.com/adv=Y&ID=123 .

The ampersand & is a reserved character in XML so you have to use &amp. If the nature of your XML file is something of the form as listed below.

 

<Advertisements>

    <Adv>

        <ImageUrl>Images/1.gif</ImageUrl>

        <NavigateUrl>http://www.c-sharpcorner.com</NavigateUrl>

        <Alt>Csharp code</Alt>

        <Caption>Csharp Site</Caption>

    </Adv>

</Advertisements>

If the first element in above file is other than <Ad> then also it gives error, it has to have very first child element as <Ad>, this is what I have observed with the code.

So it takes form like.

<Advertisements>

    <Ad>

        <ImageUrl>Images/1.gif</ImageUrl>

        <NavigateUrl>http://www.c-sharpcorner.com</NavigateUrl>

        <Alt>Csharp code</Alt>

        <Caption>Csharp Site</Caption>

    </Ad>

</Advertisements>

 

Code for Default.aspx:

 

<%@ Page Language="vb" AutoEventWireup="true"  CodeFile="Default.aspx.vb" Inherits="_Default" %>

 

<!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>

        <title>Untitled Page</title>

    </head>

    <body>

        <form id="form1" runat="server">

            <div style="text-align: left">&nbsp;

                <table>

                    <tr>

                       <td style="width: 259px">

                           <asp:Label ID="Label1" runat="server" Font-Names="Verdana" Font-Size="Smaller" Text="AdRotator Component randomly picks up ad banners from XML file and clicking on  banner takes to the specified URL" Width="301px">

                             </asp:Label>

                        </td>

                       <td style="width: 496px">

                           <asp:AdRotator ID="adRtrCtrl" Target="_self" runat="Server" />

                       </td>

                    </tr>

                </table>

            </div>

        </form>

    </body>

</html>


Code for Ads.xml file:


<
Advertisements>

    <Ad>

        <ImageUrl>Images/1.gif</ImageUrl>

        <NavigateUrl>http://www.c-sharpcorner.com</NavigateUrl>

        <Alt>Csharp code</Alt>

        <Caption>Csharp Site</Caption>

   </Ad>

   <Ad>

        <ImageUrl>Images/1.gif</ImageUrl>

        <NavigateUrl>http://www.vbdotnetheaven.com</NavigateUrl>

        <Alt>VB.Net</Alt>

        <Caption>Visual Basic</Caption>

   </Ad>

   <Ad>

        <ImageUrl>Images/3.gif</ImageUrl>

        <NavigateUrl>http://www.c-sharpcorner.com</NavigateUrl>

        <Alt>Csharp code</Alt>

        <Caption>Csharp Site</Caption>

    </Ad>

    <Ad>

        <ImageUrl>Images/4.gif</ImageUrl>

        <NavigateUrl>http://www.mindcracker.com</NavigateUrl>

        <Alt>.Net Professional Job Site</Alt>

        <Caption>VS.Net</Caption>

    </Ad>

</Advertisements>

Note: I have tested the code 5-6 times with above error.

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# Corner (http://www.c-sharpcorner.com/).

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor