为什么我的 AdRotator 不显示图像? (图片路径正确)
我正在用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我突然意识到,我显然完全间隔了 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".