• How to use AdRotator control in ASP.NET

    by  • April 26, 2014 • Microsoft ASP.NET • 0 Comments

    AdRotator control is a web server control which helps developers to display graphical advertisements on a web page. It basically displays a sequence of images from a data source normally a XML file. It works as an image slider which displays images randomly after specific time period mentioned in timer.AdRotator control uses XML file to store ad information. This XML file is commonly known as advertisement file.  It must have a starting tag of <Advertisement>. Inside <Advertisement> tag, there may be several <ad> tags. Each <Ad> tag defines each ad. Every <ad> tag can have following tags.

    ImageUrl

    It contains the URL of the image to display

    NavigateUrl

    It contains the URL of the page to be followed when ad is clicked.

    AlternateText

    It contains the text that will be displayed when image cannot be displayed.

    Keyword

    It contains the category of the ad which is used to filter for specific ads.

    Impressions

    It contains a numeric value that indicates that how often that ad will be displayed.

    Width

    It contains width of the image in pixels. It will override AdRotator control width.

    Height

    It contains height of the image in pixels. It will override AdRotator control height.

     

    Create a website in Visual Studio and add a web form

    Add a XML file in your website and write code below in it

    Add a ScriptManager control

    Now add an UpdatePanel control

    Add an AdRotator control and a Timer control inside ContentTemplate of UpdatePanel

     Now see the complete code

    AdRotator control has the AdvertisementFile attribute where we can define the XML data source file. There is another attribute KewordFilter where we can define the specific category of ads. AdRotator control has some events also which we can use to create ad information programmatically.

    You can download complete code from below link.




    Namecheap.com
    Avatar of GetCodeSnippet.com

    About

    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    Leave a Reply