Web Server Controls->ASP.NET AdRotator Control
2007-03-27 08:40
471 查看
Definition and Usage
The AdRotator control is used to display a sequence of ad images.This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad.
The predefined elements inside the <Ad> tag are listed below:
Element | Description |
---|---|
<ImageUrl> | Optional. The path to the image file |
<NavigateUrl> | Optional. The URL to link to if the user clicks the ad |
<AlternateText> | Optional. An alternate text for the image |
<Keyword> | Optional. A category for the ad |
<Impressions> | Optional. The display rates in percent of the hits |
Properties
Property | Description |
---|---|
AdvertisementFile | The path to the XML file that contains ad information |
id | A unique id for the control |
KeywordFilter | A filter to limit ads after categories |
OnAdCreated | The name of the function to be executed after the creation of the control, before page rendering |
runat | Specifies that the control is a server control. Must be set to "server" |
Target | Where to open the URL |
Examples
AdRotatorASPX Source:
<script runat="server"> Sub change_url(sender As Object, e As AdCreatedEventArgs) e.NavigateUrl="http://www.w3schools.com" End Sub </script> <html> <body> <form runat="server"> <asp:AdRotator AdvertisementFile="Ad1.xml" runat="server" OnAdCreated="change_url" target="_blank" /> </form> <p><a href="ad1.xml" target="_blank">View XML file</a></p> </body> </html> |
Output Result:
View XML file |
IF you click the link "View XML file", it will shows:
- <Advertisements> - <Ad> <ImageUrl>/banners/w6.gif</ImageUrl> <NavigateUrl>http://www.w3schools.com</NavigateUrl> <AlternateText>W3Schools Main Site</AlternateText> <Impressions>50</Impressions> <Keyword>elearning</Keyword> </Ad> - <Ad> <ImageUrl>/banners/rd_xhtml.jpg</ImageUrl> <NavigateUrl>http://www.w3schools.com/xhtml/default.asp</NavigateUrl> <AlternateText>XHTML Tutorial</AlternateText> <Impressions>50</Impressions> <Keyword>XHTML</Keyword> </Ad> </Advertisements> |
相关文章推荐
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET XML Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Table Control
- Web server Controls->ASP.NET TextBox Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control
- Web Server Controls->ASP.NET ImageButton Control
- ASP.NET AJAX Roadmap--Server Controls (11): Timer Control Overview