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:
- <asp:AsyncPostBackTrigger>
- <asp:PostBackTrigger>.
They both accept two attributes:
- ControlID
- 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:
- http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers