views:

220

answers:

3

Hi. I'm writing a simple web application in C# and I've gotten to the part where I must add an AdRotator object and link four images to it. I have done this, but no matter what I do the images will not show up; only the alternate text. It makes no sense because the paths are correct. Supposedly AdRotator controls are really simple to use... But anyway below is my code.

Search.aspx:

<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="Module6.WebForm2" Title="Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="Search" runat="server">
    This is the Search page!
    <div class="StartCalendar">
        <asp:Calendar ID="Calendar1" runat="server" Caption="Start Date" TodayDayStyle-Font-Bold="true" 
            TodayDayStyle-ForeColor="Crimson" SelectedDayStyle-BackColor="DarkCyan"  />
    </div>
    <div class="EndCalendar">
        <asp:Calendar ID="Calendar2" runat="server" Caption="End Date" TodayDayStyle-Font-Bold="true"
            TodayDayStyle-ForeColor="Crimson" SelectedDayStyle-BackColor="DarkCyan" />
    </div>
    <br /><br />
    <div class="Search">
        <asp:Button ID="btnSearch" runat="server" Text="Search" UseSubmitBehavior="true" />
    </div><br /><br />
    <div class="CenterAd">
        <asp:AdRotator ID="AdRotator1" runat="server" Target="_blank" AdvertisementFile="~/Advertisements.xml" />
    </div>
    <br /><br />
    <div class="Results">
        <asp:GridView ID="gvResults" runat="server" />
    </div>
    </form>
</asp:Content>

Advertisements.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageURL>~/images/colts.jpg</ImageURL>
    <AlternateText>Colts Image</AlternateText>
  </Ad>
  <Ad>
    <ImageURL>~/images/conseco.gif</ImageURL>
    <AlternateText>Conseco Image</AlternateText>
  </Ad>
  <Ad>
    <ImageURL>~/images/IndianapolisIndians.png</ImageURL>
    <AlternateText>Indianapolis Indians Image</AlternateText>
  </Ad>
  <Ad>
    <ImageURL>~/images/pacers.gif</ImageURL>
    <AlternateText>Pacers Image</AlternateText>
  </Ad>
</Advertisements>

Any and all help is GREATLY appreciated.

+1  A: 

So it dawned on me that I apparently COMPLETELY spaced how XML tags are case-sensitive... I could've sworn I saw the ImageUrl tags written "ImageURL" everywhere but then again maybe I just wasn't thinking.

Anyways in case anyone else has a similar issue, the ImageUrl tags are spelled "ImageUrl" and most definitely not "ImageURL".

KSwift87
A: 

Bingo! I've just spent god knows how long trying to figure that out!

Now it works!

Thanks for the post !!!!

WillEastbury
Glad you found my post useful. :-) I like to think I'm not wasting my time by answering my own questions if nobody else has answered them. lol
KSwift87
Actually I might add - If you found my answer useful, give it a vote up if ya would. 0:-)
KSwift87
A: 

Guys, I've got the same problem, and been through my Advertisements.xml file a hundred times, but still it won't display my images... In VS2010 designer it just shows the image placeholder (that small icon with the 3 shapes).

I also tried putting a normal pointing to one of the ad images, and even this doesn't display. It doesn't show the image-not-found image, it just doesn't display. When I open the source view in IE the tag is there and everything looks perfect, it just doesn't display. Any ideas??

Here is my code from .aspx:

<asp:Content ID="body" ContentPlaceHolderID="content_body" runat="server">
    <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/Advertisements.xml" />
</asp:Content>

My Advertisements.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements xmlns="http://schemas.microsoft.com/AspNet/AdRotator-Schedule-File"&gt;
  <Ad>
    <ImageUrl>Images/Advertisements/banner_1.gif</ImageUrl>
    <NavigateUrl>Default.aspx</NavigateUrl>
    <AlternateText>Advertisement</AlternateText>
  </Ad>
  <Ad>
    <ImageUrl>Images/Advertisements/banner_2.gif</ImageUrl>
    <NavigateUrl>Default.aspx</NavigateUrl>
    <AlternateText>Advertisement</AlternateText>
  </Ad>
</Advertisements>

And the source view rendered in IE:

<a id="ctl00_content_body_AdRotator1" href="/Default.aspx" target="_top">
<img src="/Images/Advertisements/banner_1.gif" alt="Advertisement" style="border-width:0px;" /></a><br />

Any help greatly appreciated!!

Andrie