Implementing Asp.net Adrotator control - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Implementing Asp.net Adrotator control

In this article I am going to explain how to implement AdRotator control of asp.net.

Description:
Adrotator control is used to show custom Ads (advertisements) on asp.net build websites. When users click on any ad they will be redirect to link assign for that. We can use both Xml and database as data source. Xml and database table must have following properties and columns: ImageUrl, NavigateUrl, AlternateText, Impressions, Keyword, Width and Height.

Implementations:
I am using Xml to implement this example. I have add Xml File.

Source of XML file (Adfile.xml)

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>~/images/mc.jpg</ImageUrl>
    <NavigateUrl>https://www.mcdonalds.com.sg</NavigateUrl>
    <AlternateText>Mcdonalds</AlternateText>
    <Impressions>50</Impressions>
    <Keyword>mcdonalds</Keyword>
    <Width>300</Width>
 <Height>250</Height>
  </Ad>
<Ad>
    <ImageUrl>~/images/vodafone.jpg</ImageUrl>
    <NavigateUrl>https://www.vodafone.in/</NavigateUrl>
    <AlternateText>Vodafone</AlternateText>
    <Impressions>50</Impressions>
    <Keyword>Vodafone</Keyword>
  <Width>300</Width>
 <Height>250</Height>
  </Ad>
   <Ad>
    <ImageUrl>~/images/pizza.png</ImageUrl>
    <NavigateUrl>https://www.pizzahut.coms</NavigateUrl>
    <AlternateText>Pizza hut</AlternateText>
    <Impressions>50</Impressions>
    <Keyword>Pizza hut</Keyword>
     <Width>300</Width>
 <Height>250</Height>
  </Ad>
</Advertisements>

Add Adrotator control to webform. We have to pass xml file path to AdvertisementFile property of control.

Complete source of webform
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/AdFile.xml" Target="_blank"/>
    </div>
    </form>
</body>
</html>


What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon