Today we will see how to make a slideshow with the adrotator control in two ways.
1. In a simple way
2. Using Ajax UpdatePanel and Timer Control to automatically update adrotator images.
- First create a new web site
- Create a XML File with the following contents:
- <Advertisements>
- <Ad>
- <ImageUrl>../images/1.jpg</ImageUrl>
- <Width>230</Width>
- <Height>320</Height>
- <NavigateUrl>http://www.google.com</NavigateUrl>
- <AlternateText>First Image</AlternateText>
- <Impressions>50</Impressions>
- <Keyword>Banner</Keyword>
- </Ad>
- <Ad>
- <ImageUrl>../images/2.jpg</ImageUrl>
- <Width>230</Width>
- <Height>320</Height>
- <NavigateUrl>http://www.google.com</NavigateUrl>
- <AlternateText>Second Image</AlternateText>
- <Impressions>40</Impressions>
- <Keyword>Banner</Keyword>
- </Ad>
- <Ad>
- <ImageUrl>../images/3.jpg</ImageUrl>
- <Width>230</Width>
- <Height>320</Height>
- <NavigateUrl>http://www.google.com</NavigateUrl>
- <AlternateText>Third Image</AlternateText>
- <Impressions>25</Impressions>
- <Keyword>Banner</Keyword>
- </Ad>
- <Ad>
- <ImageUrl>../images/4.jpg</ImageUrl>
- <Width>230</Width>
- <Height>320</Height>
- <NavigateUrl>http://www.google.com</NavigateUrl>
- <AlternateText>Fourth Image</AlternateText>
- <Impressions>60</Impressions>
- <Keyword>Banner</Keyword>
- </Ad>
- <Ad>
- <ImageUrl>../images/5.jpg</ImageUrl>
- <Width>230</Width>
- <Height>320</Height>
- <NavigateUrl>http://www.google.com</NavigateUrl>
- <AlternateText>Fifth Image</AlternateText>
- <Impressions>35</Impressions>
- <Keyword>Banner</Keyword>
- </Ad>
- </Advertisements>
After that drag an adrotator control and xmldatasource control and bind the xmldatasource to the XML file then bind the XML file bound adrotator control to the xmldatasource so that it can fetch images from the datasource provided.
- <%@ 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 id="Head1" runat="server">
- <title>Adrotar Demo By Honey Chawla.</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
- <br />
- <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Ad.xml">
- </asp:XmlDataSource><br />
- <asp:HyperLink ID="NavHyperLink1" runat="server" NavigateUrl="~/AjaxAdrotator/AjaxAds.aspx">Click To See Ajax Adrotator Demo</asp:HyperLink>
- </div>
- </form>
- </body>
- </html>




Honey ChawlaPosted Jan 9, 2014, 5:27 AM
Sorry,i didn't reply you.But thanks