Asp. NET advertising Control AdRotator usage Analysis _ Practical skills

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.