Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AdCreatedEventArgs.ImageUrl Property


Gets or sets the URL of an image to display in the AdRotator control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public string ImageUrl { get; set; }

Property Value

Type: System.String

The URL of an image to display in the AdRotator control. The default value is String.Empty.

Use the ImageUrl property to specify the URL of an image to display for an advertisement in the AdRotator control. You can use a relative or an absolute URL. A relative URL relates the location of the image to the location of the Web page or user control without specifying a complete path on the server. The path is relative to the location of the Web page. This makes it easier to move the entire site to another directory on the server without updating the path to the image in code. An absolute URL provides the complete path, so moving the site to another directory requires updating the code.

A separate XML file contains the properties for the displayed advertisement. The AdRotator control automatically sets the ImageUrl property with the corresponding image URL entry in the XML file containing the advertisement information. This property can also be used to programmatically set the image URL.


If you use an advertisement file and specify a relative URL for this property, the URL is relative to the directory that the advertisement file is located in. If you set this property directly with a relative URL, instead of using the advertisement file, the URL is relative to the directory of the page or user control that contains the AdRotator control.

The following code example demonstrates how to programmatically set the ImageUrl property.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
<head runat="server">
    <title>AdCreatedEventArgs ImageUrl Example</title>
<script runat="server">

       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 

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





   <form id="form1" runat="server">

      <h3>AdCreatedEventArgs ImageUrl Example</h3>

      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"



The following code example demonstrates how to format the XML file that contains the advertisement information. For more information on the XML file, see the AdvertisementFile property of the AdRotator class.

 <AlternateText>Microsoft Main Site</AlternateText>
 <Caption>This is the caption for Ad#1</Caption> 
 <AlternateText>Wingtip Toys</AlternateText>
 <Caption>This is the caption for Ad#2</Caption> 

.NET Framework
Available since 1.1
Return to top
© 2017 Microsoft