Go to DotNetFunda.com
 Online : 678 |  Welcome, Guest!   Login
 
Home > Articles > ASP.NET > Adrotator Control using XML, SqlDataSource and Timer Control

Submit Article | Articles Home | Search Articles |

Adrotator Control using XML, SqlDataSource and Timer Control

1 vote(s)
Rating: 4 out of 5
red flag  Posted on: 7/28/2010 5:24:31 PM by Ganeshji | Views: 499 | Category: ASP.NET | Level: Beginner


After studying a lot on Adrotator control, I came to this point, and tried my best to give my knowledge on this control to my readers. I hope u all will like this article of mine.



Introduction

The AdRotator Web Server control provides a way to display graphic images on your ASP.NET web pages. One use of the AdRotator is to show banner-style advertisements on a page. The control automatically reads advertisement information, such as the graphic file name and the target URL, from a list of ads that you provide using a data source. Here datasource may be an XML file or may be a database table also. I am going to show you examples where I have used both of these. Hope you will like it.


Properties

Some of the properties of an Adrotator Control are as follows:

 

Property

Description

AdvertisementFile

This text will be displayed if the image cannot be displayed . And in case image appears, this text acts as a tooltip.

 

NavigateUrl

The link followed when the user clicks the banner.

ImageUrl 

The link of the image that will be displayed. This may be relative link or an Internet URL.

 

Impressions

A number that sets how often an advertisement will appear.        

 

Keywords

A keyword that identifies a group of advertisements.

 



Detailed Examples


Let me site an example where  i have used Adrotator using XML:


Default.aspx



 

In the Default.aspx, I have used ScriptManager, UpdatePanel from AjaxExtensions Tab present in the Toolbox.

Let me specify the functions of these: 

When adding an UpdatePanel control to your page, you can achieve a partial-update of your page on a postback. Only the content in the UpdatePanel is refreshed, the other parts of the page remain unchanged.

 

The <Triggers> element has two sub elements:

  1. <asp:AsyncPostBackTrigger>
  2. <asp:PostBackTrigger>.
They both accept two attributes:

  1. ControlID
  2. EventName

<asp:AsyncPostBackTrigger> element is useful for a control which is within the UpdatePanel control. This makes the UpdatePanel’s content  refreshed after an asynchronous postback.

<asp:PostBackTrigger> element enables controls inside an UpdatePanel to  cause a postback. Using this element one cannot go for asynchronous postback.

Output:


The output changes the images according to the time set by the timer control.
Suppose, first this image is displayed.


After few seconds, this image is displayed;



Now all these images are linked. If you click on the above picture, u will be navigated to the Winter.aspx page.



Now let me show you another example where i have used Adrotator using SqlDataSource


 This is the table content.



Here i have simply used the DataSourceID property of the Adrotator Control to link it with the SqlDataSource. The SqlDataSource is again bound with my tblImage Table. The content of which is given above.



On running , we get the following image. As here, i haven't used the timer control, hence page refresh can only change the image. 
 


If u click on this child's image, you will be navigated to Child3.aspx




Hope you will enjoy reading my article.

References:

  1. http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers




If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Found interesting? Add this to:

| More



Please Sign In to vote for this post.

 
Latest post(s) from Ganeshji

Latest Articles
Experience:1 year(s)
Home page:
Member since:Saturday, July 24, 2010
Level:Starter
Status: [Member]
Biography:

Submit Article

About Us | The Team | Advertise | Contact Us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 9/7/2010 12:14:05 AM