Thursday, 5 September 2013

AdRotator with Timer to Rotate the Advertisement without Refreshing the page in Asp.Net






Description:-


            In this Example we explain that How to Rotate the Advertisement or Ads in your Website without Refreshing the webpage.


To Rotate the Advertise in our website the DotNet allready provide a Control For rotate the ads on page is called a AdRotator Control.

AdRotator uses an XML file to store the Add information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there are many several <Ad> tags which defines each Add.

you can also bind the Advertisement from the SqlServer Database same as we used in XML file. that is very useful because you can easily Display Advertisement in your Application or website like all website display Advertisement like Facebook,Yahoo etc.......

The predefined elements inside the <Ad> tag are listed below:

<ImageUrl> : The path to the image file

<NavigateUrl> : The URL to link to if the user clicks the Add

<AlternateText> : An alternate text for the image

<Keyword> : A category for the Add

<Impressions> : The display rates in percent of the hits


Here is a Property of adRotator control are as Follows:

Click Below Downlod Image to Download the Complete Project

download here!

Step 1:- Create XML File in App_Data Folder with name advertisement.xml and paste this code in this file.
advertisement.xml:-
<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

  <Ad>

    <ImageUrl>~/Ads/4.jpg</ImageUrl>

    <NavigateUrl>http://aspsolutionkirit.blogspot.in</NavigateUrl>

    <AlternateText>AdRotator Control sample ads</AlternateText>

    <Impressions>20</Impressions>

    <Keyword>Asp.Net</Keyword>

  </Ad>

  <Ad>

    <ImageUrl>~/Ads/5.jpg</ImageUrl>

    <NavigateUrl>http://aspsolutionkirit.blogspot.in</NavigateUrl>

    <AlternateText>AdRotator Control sample ads</AlternateText>

    <Impressions>30</Impressions>

    <Keyword>Asp.Net</Keyword>

  </Ad>

 </Advertisements>

Step 2:- Create Add Folder And paste image in this Folder that you can use in XML file with same name as image in XMl File.
  Default.aspx:-
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" Interval="500">
        </asp:Timer>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
        <asp:AdRotator ID="AdRotator1" runat="server"
                       AdvertisementFile="~/App_Data/advertisement.xml"
                       KeywordFilter="Asp.Net" />
        </ContentTemplate>
        </asp:UpdatePanel>
       
   
    </div>
    </form>
</body>
</html>


14 comments:

  1. nice 1. I have found another example for the same please visit http://www.etechpulse.com/2013/05/adrotator-how-to-rotate-advertisements.html

    Thanks

    ReplyDelete
  2. how can i rotate text in respective to images..

    ReplyDelete


  3. Given so much information in it. its very useful .perfect explanation about Dot net framework.Thanks for your valuable information. Dot Net Training in chennai | Dot Net Training in velachery

    ReplyDelete
  4. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

    angularjs training in chennai
    angularjs2 training in chennai

    ReplyDelete
  5. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Blueprism training in Chennai

    Blueprism training in Bangalore

    Blueprism training in Pune

    Blueprism online training

    ReplyDelete
  6. Thanks for sharing this advantages and disadvantages of android. Keep up the good work and share more like this.
    Devops Training in Chennai | Devops Training Institute in Chennai

    ReplyDelete
  7. All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  8. Read all the information that I had given in above article. It was giving the whole Idea respective to the topic.Such an useful time.
    great information has been shared by the blog.
    Java training in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Online Training

    ReplyDelete
  9. Thank you for taking the time to discuss this informative content with us. I feel happy about the topic that you have shared with us.
    amazon web services aws training in chennai

    microsoft azure training in chennai

    workday training in chennai

    android-training-in chennai

    ios training in chennai

    ReplyDelete
  10. A corporate enterprise cannot function effectively without human resources. He/she is in charge of the tactics that assist a company to grow. HR professionals have a distinct and crucial function in a company.

    <a href="https://www.mylearnnest.com/>best-sap-success-factors-training-in-hyderabad/</a>

    ReplyDelete