AdCreatedEventArgs.ImageUrl 属性

定义

获取或设置要在 AdRotator 控件中显示的图像的 URL。

public:
 property System::String ^ ImageUrl { System::String ^ get(); void set(System::String ^ value); };
public string ImageUrl { get; set; }
member this.ImageUrl : string with get, set
Public Property ImageUrl As String

属性值

要在 AdRotator 控件中显示的图像的 URL。 默认值是 Empty

示例

下面的代码示例演示如何以编程方式设置 ImageUrl 属性。

<%@ Page Language="C#" AutoEventWireup="True" %>

<!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 runat="server">
    <title>AdCreatedEventArgs ImageUrl Example</title>
<script runat="server">
   
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {

          e.ImageUrl = "images/newimage.jpg";   
       
       }      

   </script>
 
</head>
 
<body>
 
   <form id="form1" runat="server">
 
      <h3>AdCreatedEventArgs ImageUrl Example</h3>
 
      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>
 
   </form>
 
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!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 runat="server">
    <title>AdCreatedEventArgs ImageUrl Example</title>
<script runat="server">
   
       Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 
       
          e.ImageUrl = "images/newimage.jpg"   
       
       End Sub      

   </script>
 
</head>
 
<body>
 
   <form id="form1" runat="server">
 
      <h3>AdCreatedEventArgs ImageUrl Example</h3>
 
      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>
 
   </form>
 
</body>
</html>

下面的代码示例演示如何设置包含播发信息的 XML 文件的格式。 有关 XML 文件的详细信息,请参阅 AdvertisementFile 类的 AdRotator 属性。

<Advertisements>  
 <Ad>  
 <ImageUrl>image1.jpg</ImageUrl>  
 <NavigateUrl>http://www.microsoft.com</NavigateUrl>  
 <AlternateText>Microsoft Main Site</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic1</Keyword>  
 <Caption>This is the caption for Ad#1</Caption>   
 </Ad>  
 <Ad>  
 <ImageUrl>image2.jpg</ImageUrl>  
 <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>  
 <AlternateText>Wingtip Toys</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic2</Keyword>  
 <Caption>This is the caption for Ad#2</Caption>   
 </Ad>  
</Advertisements>  

注解

ImageUrl使用 属性指定要在 控件中为播发显示的图像的 AdRotator URL。 可以使用相对 URL 或绝对 URL。 相对 URL 将图像的位置与网页或用户控件的位置相关联,而无需在服务器上指定完整路径。 路径相对于网页的位置。 这样,无需在代码中更新映像的路径,即可更轻松地将整个站点移动到服务器上的另一个目录。 绝对 URL 提供完整路径,因此将站点移动到另一个目录需要更新代码。

单独的 XML 文件包含所显示播发的属性。 控件 AdRotator 使用包含播发信息的 XML 文件中的相应图像 URL 条目自动设置 ImageUrl 属性。 此属性还可用于以编程方式设置图像 URL。

备注

如果使用播发文件并为此属性指定相对 URL,则 URL 相对于播发文件所在的目录。 如果直接使用相对 URL 设置此属性,而不是使用播发文件,则 URL 相对于包含 AdRotator 控件的页面或用户控件的目录。

适用于

另请参阅