Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 6694 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > Adrotator Control using XML, SqlDataSource and Timer Control

Adrotator Control using XML, SqlDataSource and Timer Control

2 vote(s)
Rating: 4.5 out of 5
Article posted by Ganeshji on 7/28/2010 | Views: 4548 | Category: ASP.NET | Level: Beginner red flag


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


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


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

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:1 year(s)
Home page:
Member since:Saturday, July 24, 2010
Level:Starter
Status: [Member]
Biography:
 Responses
Posted by: Akiii | Posted on: 15 Aug 2011 08:51:26 AM | Points: 25

Nice example of Adrotator...

Keep posting...
Thanks and Regards
Akiii

Posted by: Ganeshji | Posted on: 17 Aug 2011 11:34:49 AM | Points: 25

Thnx Akii!

Posted by: Hemali | Posted on: 24 Feb 2012 03:04:12 AM | 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..

>> Write Response - Respond to this post and get points
Related Posts

This FAQ is like a starter kit. It will help you understand the main aspects of Ajax in a rapid fashion....

In this example i'll show how to detect the session timeout which occurs when user is idle for the time specified as Session.Timeout,using C# asp.NET and if it is than redirect the user to login page to login again, for this i've set time out value in web.config file to 1 minute

This article demonstrates how we can share ViewState across pages.

Guys has anybody faced problems with the Key, value pair collections not sorting the collections based on values . As all the collections sort themself on keys . As i needed a collection of Key,Value pairs which does sorting on values rather than key, For that reason i have created my own collection class which dose sorting on the values. And this is working perfectly for me .

In earlier articles, we learnt how to create, read, expire cookies and limit the scope of the cookies to a particular folder of the website . In this article we are going to learn how to limit cookie for a particular domain.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for 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. | 5/21/2012 8:18:50 AM