AdRotator.AdvertisementFile Property
Gets or sets the path to an XML file that contains advertisement information.
[Visual Basic] Public Property AdvertisementFile As String [C#] public string AdvertisementFile {get; set;} [C++] public: __property String* get_AdvertisementFile(); public: __property void set_AdvertisementFile(String*); [JScript] public function get AdvertisementFile() : String; public function set AdvertisementFile(String);
Property Value
The location of an XML file containing advertisement information. The default value is String.Empty.
Remarks
Use the AdvertisementFile property to specify the location of an XML file that contains advertisement information. The XML file must reside within the same Web site. For deployment and security purposes, it is strongly recommended that you should place the file in the same Web application. It is only possible to access an XML file that is located in a different application on the same site if the application has sufficient trust.
You can set this property to either an absolute, or a path relative to the XML file. Use a relative path to simplify deployment. If you use a relative path, that path is relative to the location of the page or user control that contains the AdRotator control.
The AdvertisementFile property is optional. An advertisement may also be programmatically set in the AdCreated event.
The XML file contains the following predefined attributes. Only the ImageUrl attribute is required.
| Attribute | Description |
|---|---|
| ImageUrl | The URL of the image to display. |
| NavigateUrl | The URL of the page to navigate to when the AdRotator control is clicked. |
| AlternateText | The text to display if the image is unavailable. On some browsers, this text is displayed as a ToolTip. |
| Keyword | The category for the advertisement. This is used by the AdRotator control to filter the list of advertisements for a specific category. |
| Impressions | A value that indicates how often an advertisement is displayed in relation to other advertisements in the XML file. |
Note The ImageUrl and NavigateUrl attributes can either be a full URL, a root-relative path, or a relative path. If you use a root-relative path, the path is relative to the same Web site. If you use a relative path, the path is relative to the directory that contains the advertisement file.
You can also include custom attributes by using custom tags in the XML file. All attribute tags are parsed from the advertisement file and the values are placed in the AdProperties dictionary. You can use the AdProperties dictionary to programmatically access your custom attributes.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the AdvertisementFile property to specify the location of the XML file that contains advertisement information.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>AdRotator Example</h3> <asp:AdRotator id="AdRotator1" runat="server" Target="_self" AdvertisementFile="Ads.xml"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>AdRotator Example</h3> <asp:AdRotator id="AdRotator1" runat="server" Target="_self" AdvertisementFile="Ads.xml"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>AdRotator Example</h3> <asp:AdRotator id="AdRotator1" runat="server" Target="_self" AdvertisementFile="Ads.xml"/> </form> </body> </html>
[Visual Basic, C#, JScript] The following example shows the file format of the XML advertisement file.
<Advertisements> <Ad> <ImageUrl>image1.jpg</ImageUrl> <NavigateUrl>http://www.microsoft.com</NavigateUrl> <AlternateText>Microsoft Main Site</AlternateText> <Impressions>80</Impressions> <Keyword>Topic1</Keyword> <Caption>This is the caption for Ad#1</Caption> </Ad> <Ad> <ImageUrl>image2.jpg</ImageUrl> <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl> <AlternateText>Wing Tip Toys</AlternateText> <Impressions>80</Impressions> <Keyword>Topic2</Keyword> <Caption>This is the caption for Ad#2</Caption> </Ad> </Advertisements>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
AdRotator Class | AdRotator Members | System.Web.UI.WebControls Namespace | AdCreated | AdCreatedEventArgs