Follow Fantora on Twitter
Fantora Word of Classified Ads and Community Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

using AdRotator control in ASP.Net

Options
zara
Posted: Tuesday, August 18, 2009 7:12:22 AM
Rank: Advanced Member
Groups: Member

Joined: 5/29/2008
Posts: 47
Points: 141
Location: California

using AdRotator control 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. It also enables you to display different types of images whenever you refresh the page. Adrotator control takes the information about the images that are to be displayed from an XML file which also have many other elements in it that are used by this control.

Adrotator control is available in ASP.Net to make the task of rotating the advertisement images in a web form quickly and easily. It also enables you to display different types of images whenever you refresh the page. Adrotator control takes the information about the images that are to be displayed from an XML file which also have many other elements in it that are used by this control.

First let us have a look at a sample advertisement file that is used by the adrotator control in ASP.Net.

Let us assume that the advertisement XML file is named as advt.xml. This file might look like,

Code:
<Advertisements>

<Ad>
<ImageUrl>site1img1.jpg</ImageUrl>
<NavigateUrl>http://www.site1.com</NavigateUrl>
<AlternateText>Site1 Main</AlternateText>
<Impressions>50</Impressions>
<Keyword>Product1</Keyword>
</Ad>

<Ad>
<ImageUrl>site2img2.jpg</ImageUrl>
<NavigateUrl>http://www.site2.com</NavigateUrl>
<AlternateText>Site2 Main Page</AlternateText>
<Impressions>75</Impressions>
<Keyword>Product2</Keyword>
</Ad>

</Advertisements>


The XML file that is used for advertisements would have the root element as the <Advertisements> element. This may have many <Ad> child elements. The elements <ImageUrl>, <NavigateUrl>, <AlternateText>, <Impressions> and <Keyword> are found in the <Ad> element. These elements identify the properties of the image that is displayed using the adrotator control.

The <ImageUrl> element specifies the path to the image that is displayed using the AdRotator control. Once a user clicks the image that is displayed the user is taken to the URL specified in the <NavigateUrl> element. The <AlternateText> element holds the text that is displayed when the image is not loaded. The text in this element is also used as a ToolTip in some of the browsers. The element <Impressions> has a number as a value. This number indicates how often the image is displayed with respect to other images. The more the value of the number in this element, the more is the frequency of the image that is displayed. The sum of all the impressions in the advertisement file should not exceed 2,047,999,999. Otherwise the AdRotator will throw an runtime exception. The element <Keyword> is used to give the category of the advertisement.

You can just drag and drop a AdRotator control in the webform and set its attributes if you are using Visual Studio .Net. The code that is generated for the AdRotator control might be something as given below:

Code:
<asp:AdRotator id="AdRotator1"
   Target="_self"
   AdvertisementFile="advt.xml"
   runat="server"/>


In the above code in the HTML
file you could see that the AdvertisementFile attribute of the AdRotator control has the xml file “advt.xml”. The other attributes are ‘id’ and ‘Target’. During runtime the AdRotator control uses the controls like <asp:HyperLink> and <asp:Image> to display the image in the web form page. The size of the image that is displayed is limited by the size of the AdRotator control that is found in the page. So, if you want to display larger images you need to adjust the size of the AdRotator control during design time itself.

It is possible to modify the values of the <ImageUrl>, <NavigateUrl> and <AlternateText> programmatically. For this you can use the AdCreated event. Thus by using the AdCreated event the rendering of the AdRotator control can be controlled.

Code:
<script runat="server">
Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs)
e.NavigateUrl = "http://www.yoursite.com" 
End Sub     
</script>


Using the above script you can modify the NavigateUrl property programmatically. This even is called in the AdRotator control as given below in the HTML code for the web form.

Code:
<asp:AdRotator id="AdRotator1" runat="server"
   AdvertisementFile = "advt.xml"
   Target="_self"
   OnAdCreated="AdCreated_Event"/>


The OnAdCreated property of the AdRotator control specifies the event that is called which changes the URL to be navigated.

Thus the AdRotator control is an easy way to display and rotate advertisements and also to give preference to some advertisements by using the <Impressions> element of the advertisement XML file.
hightech
Posted: Wednesday, August 19, 2009 12:26:32 AM
Rank: Advanced Member
Groups: Member

Joined: 9/6/2008
Posts: 227
Points: 487
Location: US

using AdRotator control in ASP.Net

Seems like useful tool to make the product more attract.

Test Management
Michael Caine
Posted: Monday, July 18, 2011 6:54:58 AM
Rank: Newbie
Groups: Member

Joined: 7/18/2011
Posts: 1
Points: 3
Location: US

using AdRotator control in ASP.Net

Whether adrotator changes image only on page refresh? Is it change the images periodically ? Can we change the timing as our requirement?




Cegonsoft Reviews
Users browsing this topic
Guest

 Related
how to remove 404 error
Linq query in MVC
creating a profile in commerce server 2009 pragmatically
A little confusion on ICallbackEventHandler
using AdRotator control in ASP.Net
Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ..
Commerce Server 2009 Starter Site step by step
nopCommerce ASP.NET/C# based opensource shopping cart Installation
MVC Application Structure
'System.Exception' was thrown
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Fantora Blog | Discount Shop UK | Discount Shop USA | Discount Shop Canada | Discount Boutique France | Discount Shop Deutschland | Discount Shop Italia | Descuento Shop España

Free Classified ads, Webmaster Forum & Technology Reviews | Fantora Free Classified Ads | Buy & Sell Electronics, Mobile phones & Accessories | fantora Forums Community | Buy & Sell DVD, Games and Consols | Free eBooks & Softwares | SEO & Affiliate Marketing Discussion | Programming Language Forum (.NET, ASP, PHP, SQL) | Free Classified Ads | General Stuff (Movies, Chat, Comics) | Free Online English Movies & Reviews | Free Online Hindi Movies & Reviews | Australia & New Zealand Immigration Forum | Europe immigration forum | Canada Immigration Forum | Ireland Immigration Forum | US Immigration Forum | United Kingdom Immigration Forum

Main Forum RSS : RSS

Powered by: YAF.NET
Copyright © AI Logica All rights reserved.
This page was generated in 0.246 seconds.