Adrotator Control using XML, SqlDataSource and Timer Control

Posted by in ASP.NET category on for Beginner level | Views : 13565 red flag
Rating: 4.5 out of 5  
 2 vote(s)

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.

 Download source code for Adrotator Control using XML, SqlDataSource and Timer Control


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.


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





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



The link followed when the user clicks the banner.


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



A number that sets how often an advertisement will appear.        



A keyword that identifies a group of advertisements.


Detailed Examples

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



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.


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 Child1.aspx

Hope you will enjoy reading my article.



Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Zinnia Sarkar
Member Level:
Member Status: Member
Member Since: 7/24/2010 12:50:40 PM
Country: India
Regards, Ganeshji

Login to vote for this post.

Comments or Responses

Posted by: Akiii on: 8/15/2011 | Points: 25
Nice example of Adrotator...

Keep posting...
Thanks and Regards
Posted by: Ganeshji on: 8/17/2011 | Points: 25
Thnx Akii!
Posted by: Hemali on: 2/24/2012 | Points: 25
Nice post.
Can u pls tell me if i want to use timer control i.e without refreshing page using SqlDataSource..
Pls tell me..
Thanx in advance..

Login to post response

Comment using Facebook(Author doesn't get notification)