Adrotator control in ASP.NET

 

Adrotator control: 

Adrotator control can be used to display different advertisements to different clients visiting the same webpage

 

Properties: 

1)Advertisementfile: specifying xml file name which contains advertisements information 

2)height: specify advertisements image height 

3)width: specify advertisement image width 

4)target: specify window to display advertisement information webpage top[default]. It will display add information. Page in the same browser window by overlopping ad image 

5)blank: it will display ad information page with in new browser window

 

Structure of advertisement information file[xml file] 

->Microsoft providing set of xml tags for storing advertisements information 

   Syntax: 

              <Advertisements> 

            <Ad> 

       </image url>…….</imageurl> 

       <navigate url>….</navigateurl> 

     <Alternate text>…</Alternate text> 

   <impressions>….</impressions> 

              </Ad>

              ……… 

     </Advertisements>

 

->Ad tag will represent one advertisement information 

->image url tag requires  advertisements image filename (or) url 

->navigate url tag requires webpage name contains ad product information 

->alternatetext tag requires tooltip top ad image. If ad image is not displayed then this text will be displayed

->impression tag requires priority of an advertisement 

 

EX:  dell ad……5[impressions] 

        Sony ad…..3[impressions] 

        Lg ad……2[impressions]

 

->the ad with more impressions will be given to more number of clients 

->xml tags are case sensitive

 

Creating website to work with adrotator 

Goto visual studio 

Start->run->devenv 

It will display main window of visual studio 

File menu->new->website->visual c#->select asp.net empty website 

Weblocation->e:\aspnet\adrotatorsite[drive:\dir\websitename] 

Visual studio create a folder with website name, in this folder website related files will be placed

 

->goto solution explorer 

    Right click on website path and select add existing item [select product image files] 

->speakers.gif,pocketpc.gif, pendant.gif 

Creat html page into website to store speakers product information 

Right click on website path and select add new item 

Select html page 

Give name as speakers.html 

 

<!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> 

    <title></title> 

</head> 

<body> 

<h1>place speakers information</h1> 

</body> 

</html>

 

Creat html page into website to store pocketpc product information 

Right click on website path and select add new item 

Select html page 

Give name as pocketpc.html  

 

<!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> 

    <title></title> 

</head> 

<body> 

<h1> place pocket pc information</h1>

</body> 

</html> 

Creat html page into website to store pendant product information 

Right click on website path and select add new item 

Select html page 

Give name as pendant.html 

 

<!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> 

    <title></title> 

</head> 

<body> 

<h1> place pendant information</h1>

</body> 

</html>

 

Creat xml file into website to store advertisements information 

Right click on website path and select add new item 

Select xml file 

Give name as adinto.xml

 

<?xmlversion="1.0"encoding="utf-8" ?> 

<Advertisements> 

  <Ad> 

    <ImageUrl>speakers.gif</ImageUrl> 

    <NavigateUrl>speakers.html</NavigateUrl> 

    <AlternateText>sony speaker AD</AlternateText> 

    <Impressions>5</Impressions> 

  </Ad> 

  <Ad> 

    <ImageUrl>pocketpc.gif</ImageUrl> 

    <NavigateUrl>pocketpc.html</NavigateUrl> 

    <AlternateText>nokia pocket pc AD</AlternateText> 

    <Impressions>3</Impressions> 

    </Ad> 

  <Ad> 

    <ImageUrl>pendant.gif</ImageUrl> 

    <NavigateUrl>pendant.html</NavigateUrl> 

    <AlternateText>tans pendant AD</AlternateText> 

    <Impressions>2</Impressions> 

  </Ad> 

</Advertisements>

 

Add webform 

Goto view menu and select solution explorer 

Right click on website path and select add new item 

Select webform 

Give name as home.aspx  

 

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

<!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>

    </div>

    </form> 

</body> 

</html>

 

goto design part 

Place adrotator control 

 properties of adrotator1 properties 

Advertisementfile…… 

                                       ……[click] 

                                           Select adinfo.xml 

Height-150 

Width-150 

Target-…blank

Goto control F5 

Product image display 

[click]….->product information webpage will be displayed in new browser window

 

Rotating advertisements to each clients: 

->This requires refreshing webpage at regular interval without user interaction this can be done using metatag 

->goto source view of home.aspx 

             <head> 

          <meta http-equiv=”refresh” content=5; 

Control F5

 

Note: In this above case meta tag is intracting browser to refresh webpage at regular interval of 5 secs..