次の方法で共有


AdCreatedEventArgs.ImageUrl プロパティ

AdRotator コントロールに表示するイメージの URL を取得または設定します。

Public Property ImageUrl As String
[C#]
public string ImageUrl {get; set;}
[C++]
public: __property String* get_ImageUrl();public: __property void set_ImageUrl(String*);
[JScript]
public function get ImageUrl() : String;public function set ImageUrl(String);

プロパティ値

AdRotator コントロールに表示するイメージの URL。既定値は String.Empty です。

解説

ImageUrl プロパティを使用して、 AdRotator コントロールの広告に表示するイメージの URL を指定します。相対 URL または絶対 URL を使用できます。相対 URL は、サーバー上の完全パスを指定せずに、イメージの位置を Web ページまたはユーザー コントロールの位置と関連付けます。このパスは、Web ページの位置に対する相対パスです。これにより、コード内でイメージのパスを更新しなくても、サーバー上の別のディレクトリにサイト全体を簡単に移動できます。絶対 URL では完全パスを指定するため、サイトを他のディレクトリに移動する場合は、コードを更新する必要があります。

各 XML ファイルには、表示される広告のプロパティが含まれています。 AdRotator コントロールは、 ImageUrl プロパティを、広告情報を格納している XML ファイルの対応するイメージ URL エントリに自動的に設定します。このプロパティは、イメージの URL をプログラムから設定するときにも使用できます。

メモ   広告ファイルを使用して、このプロパティの相対 URL を指定すると、URL は、広告ファイルがあるディレクトリに対する相対 URL になります。広告ファイルを使用せずに、このプロパティを相対 URL で直接設定すると、URL は、 AdRotator コントロールを含むページまたはユーザー コントロールのディレクトリに対する相対 URL になります。

使用例

[Visual Basic, C#, JScript] プログラムから ImageUrl プロパティを設定する方法を次の例に示します。

 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
   
       Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 
       
          e.ImageUrl = "images/newimage.jpg"   
       
       End Sub      

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

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

<html>
<head>

   <script runat="server">
   
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {

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

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

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
   
       function AdCreated_Event(sender : Object, e : AdCreatedEventArgs)
       {

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

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

[Visual Basic, C#, JScript] 広告情報を含む XML ファイルの書式を設定する方法を次の例に示します。XML ファイルの詳細については、 AdRotator クラスの AdvertisementFile プロパティのトピックを参照してください。

<Advertisements>
 
 <Ad>
 <ImageUrl>image1.jpg</ImageUrl>
 <href>https://www.microsoft.com</href>
 <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>
 <href>http://www.wingtiptoys.com</href>
 <AlternateText>Wing Tip Toys</AlternateText>
 <Impressions>80</Impressions>
 <Keyword>Topic2</Keyword>
 <Caption>This is the caption for Ad#2</Caption> 
 </Ad>
 
</Advertisements>

[C++] C++ のサンプルはありません。Visual Basic、C#、および JScript のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

参照

AdCreatedEventArgs クラス | AdCreatedEventArgs メンバ | System.Web.UI.WebControls 名前空間 | AdRotator | AdvertisementFile | String.Empty