Share via


ImageKey Property

Returns the element name from which the image URL is retrieved from an advertisement. The default value is imageUrl.

public string ImageKey {
   get,
   set
}

Remarks

The default is usually sufficient for compatibility with the Web Forms AdRotator class. However, individual <Choice> elements might override this setting to show alternate images for the advertisement.

Example

The following example demonstrates how to use the ImageKey property to specify the path for the image file..

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   
   'The value of the ImageKey property is taken from the .xml file.
   Adrotator1.AdvertisementFile="ads.xml" 
   Adrotator1.ImageKey = "ImageUrl1"
   Adrotator1.Visible = True
 
End Sub
//Ads.xml file:
<?xml version="1.0" ?>
<Advertisements>
    <Ad>
        <ImageUrl>msaui.gif</ImageUrl>
        <ImageUrl1>msaui2.gif</ImageUrl1>
        <NavigateURL>https://www.microsoft.com</NavigateURL>
        <NavigateURL1>http://www.margiestravel.com</NavigateURL1>
        <AlternateText>This link should work</AlternateText>
        <Keyword>HTML</Keyword>
        <Impressions>80</Impressions>
    </Ad>
</Advertisements>   

[C#]

public void Page_Load(Object source, EventArgs e)
{
   //The value of the ImageKey property is taken from the .xml file.
   Adrotator1.AdvertisementFile="ads.xml"
   Adrotator1.ImageKey = "ImageUrl1"; 
   Adrotator1.Visible = true;
}
//Ads.xml file:
<?xml version="1.0" ?>
<Advertisements>
    <Ad>
        <ImageUrl>msaui.gif</ImageUrl>
        <ImageUrl1>msaui2.gif</ImageUrl1>
        <NavigateURL>https://www.microsoft.com</NavigateURL>
        <NavigateURL1>http://www.margiestravel.com</NavigateURL1>
        <AlternateText>This link should work</AlternateText>
        <Keyword>HTML</Keyword>
        <Impressions>80</Impressions>
    </Ad>
</Advertisements>   

See Also

<Choice> Element

Applies to: AdRotator Class