Home > DeveloperSection > Blogs > AdRotator in ASP.NET

AdRotator in ASP.NET


.NET C#  ASP.Net 
Ratings:
0 Comment(s)
 693  View(s)
Rate this:

AdRotator in ASP.NET

In this blog, I’m explaining about AdRotator in ASP.Net

 

The AdRotator control presents ad images that, when clicked, navigate to a new web location. Each time the page is loaded into the browser, an ad is randomly selected from a predefined list.

Attributes                                                   Description

ImageURL                                           The URL of the image to display.

NavigateURL                                      The web location to navigate to when the image is clicked.

                                                                   If NavigateUrl is not set, the image is not clickable.

AlternateText                                     The text to display if the image is unavailable.

Keyword                                               The category of the ad, which can be used to filter for                                                                                   specific ads.

Impressions                                         This display rates in percent of the hits.

NOTE: All attributes are optional.

1.      To create ad list as an XML file.

2.Create an ad element inside the Advertisements element for each ad that you want to include in the ad list and then save the file.

<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

  <Ad>

    <ImageUrl>~/images/A.jpg</ImageUrl>

    <width>40px </width>

    <height>50px</height>

 <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1228</NavigateUrl>

  

    <AlternateText>DotNetCurry Home Page</AlternateText>

    <Impressions>40</Impressions>

    <Keyword>small1</Keyword>

  </Ad>

  <Ad>

    <ImageUrl>~/images/B.jpg</ImageUrl>

   <width>40px </width>

    <height>50px</height>

    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1034</NavigateUrl>

    <AlternateText>DotNetCurry Home Page</AlternateText>

    <Impressions>40</Impressions>

    <Keyword>small2</Keyword>

  </Ad>

  <Ad>

    <ImageUrl>~/images/C.jpg</ImageUrl>

    <width>40px</width>

    <height>50px</height>

    <NavigateUrl>http://www.dotnetcurry.com</NavigateUrl>

    <AlternateText>DotNetCurry Home Page</AlternateText>

    <Impressions>40</Impressions>

    <Keyword>small</Keyword>

  </Ad>

</Advertisements>

 

2.      Create a AdRotatorFIle.aspx

(Rotate Ads without Refreshing the page using AdRotator and ASP.NET Ajax)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdRotator.aspx.cs" Inherits="AdRotatorProject.AdRotator" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

         <div style="width: 100%;">

            <asp:ScriptManager ID="ScriptManager1" runat="server" />

            <asp:Timer ID="Timer1" Interval="2000" runat="server" />

            <asp:UpdatePanel ID="up1" runat="server">

                <Triggers>

                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

                </Triggers>

                <ContentTemplate>

                    <asp:AdRotator

                        ID="AdRotator1"

                        AdvertisementFile="~/AdRotator.xml"

                        runat="server" Target="_top" Width="500px" />

               </ContentTemplate>

            </asp:UpdatePanel>

        </div>

 

    </form>

</body>

</html>

Output:

 

 


Don't want to miss updates? Please click the below button!

Follow MindStick