Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

AdRotator - Detect duplicate images on page

Hi

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!

Marty
0
martypitt
Asked:
martypitt
  • 2
1 Solution
 
rundkaasCommented:
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)
        {
            populateCollection();
        }
        reset();
        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.
0
 
rundkaasCommented:
clarification there should be a break in the while, after a.Used = true;
Also this eventListener should be added to all adRotators
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now