Using ADRotator Control in our web apps

ADRotator:
Adrotator control is one of the rich contorls, Rich Controls are server sided controls that can be used to create complex HTML elements. rich controls provide the developer with complex functionality without having to manually wrote the code to provide that functionality.


Internet advertising is one of the major means of earning revenu for a web site. while viewing the site, the advertisements keep changing.Having a control to change the advertisements continously can reduce a lot of coding. In asp.net the ad rotator control can perform the functionality required for changing the advetisements.

Download Source code


the advertisents to be displayed need to be taken fron a life. Let us consider an XML file for the same. An ad element has to be added to describe each advertisement.

Here in my example shows an XML file that contains Ad element to describe the advertisements.
adds.xml

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>Images/1.gif</ImageUrl>
    <NavigateUrl>http://www.deliciousdotnet.blogspot.com/</NavigateUrl>
    <AlternateText>Alt Text</AlternateText>
    <Keyword>Computers</Keyword>
   
  </Ad>
  <Ad>
    <ImageUrl>Images/2.gif</ImageUrl>
    <NavigateUrl>http://www.deliciousdotnet.blogspot.com/</NavigateUrl>
    <AlternateText>Alt Text</AlternateText>
    <Keyword>Computers</Keyword>
    
  </Ad>
  <Ad>
    <ImageUrl>Images/3.gif</ImageUrl>
    <NavigateUrl>http://www.deliciousdotnet.blogspot.com/</NavigateUrl>
    <AlternateText>Alt Text</AlternateText>
    <Keyword>Computers</Keyword>
   
  </Ad>
</Advertisements>

Now after creating the advertisment file. the ad rotator control that will rotate these advertisements on the web site munst be created. The following code will create an ad rotator with the id "AdRotator1" that oicks the advertisements from the adds.xml
<body>
    <form id="form1" runat="server">
    <div>   
        
                   <asp:AdRotator ID="AdRotator1" AdvertisementFile="adds.xml" BorderWidth="1" 
                            runat="server" Height="300px" Width="300px" /> 
    </div>
    </form>
</body>

Download Source code

Share it

2 comments:

  • Vee Eee Technologies said... December 6, 2011 at 12:06 PM

    Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

  • Pravesh Singh said... January 11, 2012 at 1:49 PM

    Hi,

    I was reading your article and I would like to appreciate you for making it very simple and understandable. This article gives me a basic idea of AdRotator Control in Asp.Net and it helped me a lot. Thanks for sharing with us. Check out this link too its also having nice post with wonderful explanation on AdRotator control....

    AdRotator Control in ASP.Net

    Thank you very much for your precious post!!

Post a Comment