Working with mmAdRotator

mmAdRotator is a direct subclass of the standard AdRotator control which has been extended by adding MM .NET data binding.

Displaying Ads from a Database Using mmAdRotator

  1. If you do not already have a database table that contains ad information, create a table with the following schema (all columns except ID are optional):

    Column Name DataType Description
    ID int Primary key. This column can have any name.
    ImageUrl nvarchar The relative or absolute URL of the image to display for the ad.
    NavigateUrl nvarchar The target URL for the ad. If you do not provide a value, the ad is not a hyperlink.
    AlternateText nvarchar The text displayed if the image cannot be found. In some browsers, the text is displayed as a ToolTip. Alternate text is also used for accessibility so that users who cannot see the graphic can hear it.
    Keyword nvarchar A category for the ad on which the page can filter.
    Impressions int(4) A number that indicates the likelihood of how often the ad is displayed. The larger the number, the more often the ad will be displayed. The total of all impressions values in the XML file may not exceed 2,048,000,000 - 1
    Width int(4) The width of the image in pixels.
    Height int(4) The height of the image in pixels.

  2. If you already have an existing database table with ad information in it you can set the following properties of the mmAdRotator control to map your database table schema to the fields required by the control (Note: these are standard .NET properties, not MM .NET-specific):

    • AlternateTextField
    • ImageUrlField
    • NavigateUrlField

  3. If you haven't already donen so, populate the table with ad information

  4. Create a business object method that retrieves records from the ad table.

    For example, in C#:

    	/// <summary>
    /// Summary description for Advertisement.
    /// </summary>
    public class Advertisement : ABusinessObject
    {
    	public Advertisement()
    	{
    		this.TableName = "Advertisement";
    		this.PrimaryKey = "AdvertisementPK";
    	}
    
    	public DataTable GetAdsToRotate()
    	{
    		DataSet ds = this.GetDataSet("GetAdsToRotate", CommandType.StoredProcedure);
    		return ds.Tables[this.TableName];
    	}
    }

    And in VB .NET:

    ''' <summary>
    ''' Summary description for Advertisement.
    ''' </summary>
    Public Class Advertisement
       Inherits ABusinessObject
       
       Public Sub New()
          Me.TableName = "Advertisement"
          Me.PrimaryKey = "AdvertisementPK"
       End Sub 'New
       
       Public Function GetAdsToRotate() As DataTable
          Dim ds As DataSet = Me.GetDataSet("GetAdsToRotate", CommandType.StoredProcedure)
          Return ds.Tables(Me.TableName)
       End Function 
    
    End Class

  5. Register the business object with the form and call the method to retrieve ads to be rotated.

    For example, in C#:

    public partial class MyWebForm : mmBusinessWebPage
    {
    	protected Advertisement oAdvertisement;
    
    	/// <summary>
    	/// Page Load handler
    	/// </summary>
    	/// <param name="sender">Event source</param>
    	/// <param name="e">Event args</param>
    	protected void Page_Load(object sender, EventArgs e)
    	{
    		this.oAdvertisement = (Advertisement)this.RegisterBizObj(new Advertisement());
    		this.oAdvertisement.GetAdsToRotate();
    	}
    }

    And in VB .NET:

    Public Partial Class MyWebForm
       Inherits mmBusinessWebPage
    
       Protected oAdvertisement As Advertisement
       
       ''' <summary>
       ''' Page Load handler
       ''' </summary>
       Protected Sub Page_Load(sender As Object, e As EventArgs)
          Me.oAdvertisement = CType(Me.RegisterBizObj(New Advertisement()), Advertisement)
          Me.oAdvertisement.GetAdsToRotate()
       End Sub
    
    End Class

  6. Drag and drop an mmAdRotator control on your web form.

  7. In the Properties Window, select the BindingSource property, click its associated ellipses button [...] and in the Binding Source Selection dialog select the business object that you registered in the previous step then click OK. For example:

Now you should be able to run your web form and see ads rotated through each time you refresh the page:


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/18
Comment or report problem with topic