为什么我的 AdRotator 不显示图像? (图片路径正确)

发布于 2024-08-28 22:47:29 字数 2445 浏览 9 评论 0原文

我正在用 C# 编写一个简单的 Web 应用程序,并且已经到了必须添加 AdRotator 对象并将四个图像链接到它的部分。我已经这样做了,但是无论我做什么,图像都不会显示;仅替代文本。这是没有意义的,因为路径是正确的。据说 AdRotator 控件使用起来非常简单......但无论如何,下面是我的代码。

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>

Advertises.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>

非常感谢任何和所有帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南薇 2024-09-04 22:47:29

所以我突然意识到,我显然完全间隔了 XML 标签如何区分大小写...我可以发誓我看到 ImageUrl 标签到处写着“ImageURL”,但话又说回来,也许我只是没有想到。

无论如何,如果其他人有类似的问题,ImageUrl 标签拼写为“ImageUrl”,并且绝对不是“ImageURL”。

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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文