The AdRotator control in asp.net csharp present ad images that when clicked, Navigated to a new web location.Each time the page is loaded into the browser an ad is randomly selected from a predefined list. The rotation file defines the following the attributes of each ad. Except for ImageUrl, these attributes are optional in asp.net csharp. The predefined elements inside the <Ad> tags are listed below :
- ImageUrl : An absolute or relative URL to the ad Image File.
- NavigateUrl :The web location to navigate to when the image is clicked. If NavigateUrl is not set the image is not clickable.
- AlternativeText :The text to render as the ALT attribute of the image when the page is viewed with Microsoft Internet explorer this acts as a tooltip for the ad
- Keyword -: Specifies a category for the ad that the page can filter on.
- Impressions -: a number that indicates the “weight” of the ad in the schedule of rotation relative to the other ads in the file. The larger the number the more often the ad will be displayed.
Property of Adrotator in asp.net csharp -: Like the other control adrotator has its own property.There are some property are same like label control and some are different .There are some property has been given here.
- AdvertisementFIle-: The path of the xml file that contains ad information.
- AlternateTextField -: a data field to use instead of the alt text for an advertisement.
- ImageUrlField -: a data field to use instead of the imageUrl attribute for an advertisement.
- Keywordfilter : A filter to limit ads after category.
- NavigateUrlField-: A data field to use instead of the navigateUrl attribute for an advertisement.
- Target : where to open the URL
Add XML File -: Adrotator is use for xml file. First go to solution explorer and right click on the website. A menu will open there select add button now sub menu will open here select add new item and click it. Now a dialogue box will open.Now choose xml file here as like
Here we can change the name of xml file.And click the add button for adding xml file in our web page.Now do the coding in xml page here as like
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>
Rose.jpg
</ImageUrl>
<NavigateUrl>http://www.netnic.org</NavigateUrl>
<Impressions>20</Impressions>
</Ad>
<Ad>
<ImageUrl>
AArya.jpg
</ImageUrl>
<NavigateUrl>http://www.netnic.org/textbox-control-in-asp-net-csharp/</NavigateUrl>
<Impressions>20</Impressions>
</Ad>
</Advertisements>
How to add xml file to adrotator control –: Now attaching the xml file to adrotator go to the adrotator control and select advertisements property and give the path of xml file. Now run the program all the image are showing.