Wednesday, 4 April 2012

AdRotator Example

How to use AdRotator Control in Asp.Net. 

 

AdRotator is one of the Rich Web Controls available in ASP.NET. AdRotator control is available in ASP.Net to make the task of rotating the advertisement images in a web form quickly and easily.

To implement this concept you need to follow the below steps :

Step1:
Create a new Asp.net website in Visual Studio and  write the following html code in the Source Page of the Default.aspx page.

AdRotator.aspx (Source Page)

<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" />
</div>
<div>
<asp:Timer ID="Timer1" Interval="200" runat="server" />

    <asp:UpdatePanel ID="up1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" />
        </Triggers>
        <ContentTemplate>
            <asp:AdRotator
            id="AdRotator1"
            AdvertisementFile="~/adrotate.xml"
            Runat="server" Height="300px" Width="500px" />
        </ContentTemplate>
    </asp:UpdatePanel>
      </div>
    </form>
</body>
</html>

Step2: 
Now write the following code in Xml Page.

AdRotator.aspx (Xml Page)

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>Koala.jpg</ImageUrl>
  </Ad>
  <Ad>
    <ImageUrl>Lighthouse.jpg</ImageUrl>
  </Ad>
  <Ad>
    <ImageUrl>Hydrangeas.jpg</ImageUrl>

  </Ad>
</Advertisements>


Step3:
Now build the Solution and Debug it for the output.

OutPut :



 

No comments:

Post a Comment

CRUD operations using AngularJS in Asp.Net MVC

In this article I will show you how to perform CRUD operations in Asp.Net MVC5 using AngularJS. Add AngularJS using the Manage Nuget Pack...