How to: Select Ads in an AdRotator Web Server Control Programmatically
Using theWeb server control, you can dynamically select ads by creating custom logic within an event handler.
To select ads using the AdCreated event
Create an AdCreated event handler for the AdRotator control.
The second parameter passed in the handler contains a reference to the ad that is being created.
Set the properties of the ad object to specify the image and navigation URLs of the ad to display.
The following example shows how you can set the, , and properties of the control:
Public Sub AdRotator1_AdCreated(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs) _ Handles AdRotator1.AdCreated e.ImageUrl = "images/contoso_ad.gif" e.NavigateUrl = "http://www.contoso-ltd.com/" e.AlternateText = "Ad for Contoso, Ltd. Web site" End Sub