The example in this article describes the AdRotator usage of asp.net ad controls. Share to everyone for your reference, specific as follows:
Adpotator controls are often used to display advertisements on a page. It randomly displays a picture from the list that can be stored in a separate XML file or in a data-bound data source. Either way, the list contains the properties of the picture, the path, and the URL to link to when you click the picture. The picture will change every time the page loads.
An ad file is an XML file that contains information about the advertisement that is displayed by the AdRotator control. The location and file name of the file are specified by the control's AdvertisementFile property.
The location of the ad file can be relative to the root of the site, or it can be an absolute path. If its location is not in the same Web site, make sure that the application has access to the file, especially after deployment. Because of this and other security reasons, it is best to put the file in the Web root directory.
Note: The AdvertisementFile property cannot be set at the same time as the DataSource, DataMember, or DataSourceID properties. That is, if the data originates from an ad file, it cannot originate from the data source at the same time, and vice versa.
If you do not use ad files, but instead create an ad programmatically, you need to enter the code in the AdCreated event to display the desired element.
Example1
The advertisement picture is placed in the image file, the. xml file is placed in the App_Data folder,
The contents of the Ad.xml folder are:
<?xml version= "1.0" encoding= "Utf-8"?>
<Advertisements>
<Ad>//This is the beginning of an advertisement
< imageurl>~/image/gtd.jpg</imageurl>//Picture store address
<navigateurl>http://www.baidu.com</ navigateurl>//AD link address
<ALTERNATETEXT>GTD time management </AlternateText>//Alternate text
<Keyword> time management </Keyword>//keywords
<Impression>10</Impression>//The frequency of the occurrence
</Ad> <ad compared with other
ads >
</Ad>
</Advertisements>
More interested readers of asp.net related content can view the site topics: "asp.net string operation tips Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", "ASP.net Ajax Skills Summary topics" and " Summary of ASP.net caching operation techniques.
I hope this article will help you to ASP.net program design.