Export (0) Print
Expand All

AdRotator Class

Displays an advertisement banner on a Web page.

For a list of all members of this type, see AdRotator Members.

System.Object
   System.Web.UI.Control
      System.Web.UI.WebControls.WebControl
         System.Web.UI.WebControls.AdRotator

[Visual Basic]
Public Class AdRotator
   Inherits WebControl
[C#]
public class AdRotator : WebControl
[C++]
public __gc class AdRotator : public WebControl
[JScript]
public class AdRotator extends WebControl

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

Use the AdRotator control to display a randomly selected advertisement banner on the Web page. The displayed advertisement can change whenever the page refreshes.

Advertisement information is stored in a separate XML file. The XML file allows you to maintain a list of advertisements and their associated attributes. Attributes include the path to an image to display, the URL to link to when the control is clicked, the alternate text to display when the image in not available, a keyword, and the frequency of the advertisement.

As an alternative source of data to an XML file, it is possible to provide advertisement information through a call-back event. This event can also be used in combination with the XML file to extend the behavior of the AdRotator control, such as redirecting to another page. See the AdvertisementFile property for additional information on the file format.

A new advertisement is selected whenever the Web page refreshes. An Impressions attribute can be assigned to each advertisement. It controls how often an advertisement is selected relative to the other advertisements in the advertisement file.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the AdRotator control to display an advertisement banner on a Web page.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
 
 <head>
 </head>
 
 <body>
    <form runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="Ads.xml"/>
 
    </form>
 </body>
 
 </html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 
 <head>
 </head>
 
 <body>
    <form runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="Ads.xml"/>
 
    </form>
 </body>
 
 </html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
 
 <head>
 </head>
 
 <body>
    <form runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="Ads.xml"/>
 
    </form>
 </body>
 
 </html>

[Visual Basic, C#, JScript] The following example demonstrates the file format for an XML file that contains advertisement information. For more information on the file format see the AdvertisementFile member.

<Advertisements>
 
 <Ad>
 <ImageUrl>image1.jpg</ImageUrl>
 <NavigateUrl>http://www.microsoft.com</NavigateUrl>
 <AlternateText>Microsoft Main Site</AlternateText>
 <Impressions>80</Impressions>
 <Keyword>Topic1</Keyword>
 </Ad>
 
 <Ad>
 <ImageUrl>image2.jpg</ImageUrl>
 <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>
 <AlternateText>Wing Tip Toys</AlternateText>
 <Impressions>80</Impressions>
 <Keyword>Topic2</Keyword>
 </Ad>
 
</Advertisements>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web (in System.Web.dll)

See Also

AdRotator Members | System.Web.UI.WebControls Namespace | AdCreatedEventArgs | AdCreatedEventHandler | AdvertisementFile

Show:
© 2014 Microsoft