Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ad_rotator.aspx

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Ad_rotator.aspx.cs" Inherits="Ad_rotator" %>

<!DOCTYPE html>

<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="~/AdvertisementsData.xml" ImageUrlField="ImageUrl" NavigateUrlField="NavigateUrl" AlternateTextField="AlternateText" BorderWidth="1" BorderColor="blue" keywordFilter="jquery"/>

    </div>
    </form>
</body>
</html>


CSS
AdvertisementsData.xml
<pre lang="xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;Advertisements&gt;
  &lt;Ad&gt;
    &lt;ImageUrl&gt;~/itc.gif&lt;/ImageUrl&gt;
    &lt;NavigateUrl&gt;http://www.itfunda.com/aspnet-ajax-ebook/show/46  &lt;/NavigateUrl&gt;
    &lt;AlternateText&gt; Go To Asp.net Ajax ebook &lt;/AlternateText&gt;
    &lt;impression&gt;30&lt;/impression&gt;
    &lt;keyword&gt; Asp.net Ajax ebook&lt;/keyword&gt;
 &lt;/Ad&gt;

  &lt;Ad&gt;
    &lt;ImageUrl&gt;~/itfunda.gif&lt;/ImageUrl&gt;
    &lt;NavigateUrl&gt;http://www.itfunda.com/jquery-how-to-ebook/show/45  &lt;/NavigateUrl&gt;
    &lt;AlternateText&gt; Go To Jquery ebook + video + sourcecode &lt;/AlternateText&gt;
    &lt;impression&gt;20&lt;/impression&gt;
    &lt;keyword&gt; jquery&lt;/keyword&gt;

  &lt;/Ad&gt;

  &lt;Ad&gt;
    &lt;ImageUrl&gt;~/itcj.gif&lt;/ImageUrl&gt;
    &lt;NavigateUrl&gt;http://www.itfunda.com/jquery-essentials-online-training/show/41&lt;/NavigateUrl&gt;
    &lt;AlternateText&gt; Go To jquery essential training &lt;/AlternateText&gt;
    &lt;impression&gt;10&lt;/impression&gt;
    &lt;keyword&gt; jquery &lt;/keyword&gt;
  &lt;/Ad&gt;
&lt;/Advertisements&gt;</pre>
Posted
Comments
Do you see any error in Developer Tool console window?

1 solution

if you want to change change images in time intervals you need to use timer and place timer and adrotator in updatepanel, and in xml file you need to give height and width for the ad, look at below code

Replace your code with this

XMA File


XML
<advertisements>
  <ad>
  <imageurl>~/itc.gif</imageurl>
  <navigateurl>http://www.itfunda.com/aspnet-ajax-ebook/show/46  </navigateurl>
  <alternatetext> Go To Asp.net Ajax ebook </alternatetext>
    <width>300</width>
    <height>300</height>
    <impression>30</impression>
    <keyword>Asp.net Ajax ebook</keyword>
  </ad>
  <ad>
  <imageurl>~/itcfunda.gif</imageurl>
  <navigateurl>http://www.itfunda.com/jquery-how-to-ebook/show/45  </navigateurl>
  <alternatetext> Go To Jquery ebook + video + sourcecode </alternatetext>
    <width>300</width>
    <height>300</height>
    <impression>20</impression>
    <keyword>jquery</keyword>
 </ad>
  <ad>
  <imageurl>~/itcj.gif</imageurl>
  <navigateurl>http://www.itfunda.com/jquery-essentials-online-training/show/41</navigateurl>
  <alternatetext> Go To jquery essential training </alternatetext>
    <width>300</width>
    <height>300</height>
    <impression>10</impression>
    <keyword>jquery</keyword>
  </ad>
</advertisements>




ASPX:

XML
<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:UpdatePanel ID="UpdtPnlAds" runat="server">
                <ContentTemplate>
                    <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/AdvertisementsData.xml"
                        BorderWidth="1" BorderColor="blue" />
                    <asp:Timer ID="TmrAds" Interval="2000" runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900