AdRotator - Detect duplicate images on page

Posted on 2006-04-14
Last Modified: 2012-05-05

I have 4 ad rotators on the one page.  I'd like to have them all using the same XML file / db query, but would like to ensure that there's no duplicate images shown.

I figured I could create a collection of displayed images on the page, and use the adcreated event to capture the ad being displayed, check the collection and if no duplicates, display it.

However, if it IS duplicated, how do I get the control to select the next from the list.  I intend to use the Impressions tag to provide weighted impressions, so would like to allow the adrotator to continue managing the selection of the next image.  Is there a way I can do this?

Any alternative approaches would be accepted!

Question by:martypitt
    LVL 3

    Accepted Solution

    Yes I would belive that a manual approach would be best suited, so I would go for the adCreated event.
    Here is some psudocode that may help:
        private List<Ad> collection;
    protected void adRotator_AdCreated(object sender, AdCreatedEventArgs e)
            if (collection == null)
            Random rand = new Random();
            //get a random ad, or add support for the weighted impressions
            Ad a;
            while (!(a = collection[rand.Next(0, collection.Count)]).Used)
                //bind the unused ad
                //and set it to be used
                a.Used = true;
        private void populateCollection()

        private void reset()
            //sets all ads to unused
    What remains to be implemented is the Ad class, the population method and a more sophisticated selection.
    LVL 3

    Expert Comment

    clarification there should be a break in the while, after a.Used = true;
    Also this eventListener should be added to all adRotators

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now