System.Web.UI.WebControls.AdRotator.AdvertisementFile Property

Gets or sets the path to an XML file that contains advertisement information.

Syntax

[System.ComponentModel.Editor("System.Web.UI.Design.XmlUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
[System.ComponentModel.DefaultValue("")]
[System.ComponentModel.Bindable(true)]
[System.Web.UI.UrlProperty]
public string AdvertisementFile { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Use the AdRotator.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 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 path 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 System.Web.UI.WebControls.AdRotator control.

The AdRotator.AdvertisementFile property is optional. An advertisement can also be programmatically set in the AdRotator.AdCreated event.

The XML file contains the following predefined attributes. Only the ImageUrl attribute is required.

ImageUrl

The URL of the image to display.

Height

The height of the image, in pixels (optional).

Width

The width of the image, in pixels (optional).

NavigateUrl

The URL of the page to navigate to when the System.Web.UI.WebControls.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 System.Web.UI.WebControls.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 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 AdCreatedEventArgs.AdProperties dictionary. You can use the AdCreatedEventArgs.AdProperties dictionary to programmatically access your custom attributes.

Information in this file is not validated by the System.Web.UI.WebControls.AdRotator control. To prevent ads from executing malicious scripts, you should always check the data before releasing it, or accept ad information only from trusted sources.

To secure your advertisement file from unauthorized Internet access, do one or more of the following:

  • Store it in the Data directory, which is configured in Machine.config to deny Internet access for files of any type.

  • Rename the file with an extension that is not .xml, and map the extension to HttpForbiddenHandler in Web.config. For more information, see the httpHandlers section in your Machine.config file.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0