ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources]

G. andrew Duthie; matthew Macdonald

نسخه متنی -صفحه : 873/ 560
نمايش فراداده

AdRotator.NET 1.1, disposable

System.Web.UI.MobileControls (system.web.mobile.dll)class

The AdRotator control allows you display a randomly selected image on a mobile page. Every time the page is refreshed, a new image will be selected from the list specified in the associated XML configuration file (referenced by the AdvertisementFile property). The AdRotator works in almost exactly the same manner as the full-scale ASP.NET System.Web.UI.WebControls.AdRotator web control, using the same XML configuration file format, and raising the same AdCreated event (which allows you to update other parts of the mobile page to correspond with the dynamically selected advertisement). The only significant difference is the addition of the ImageKey property, which allows you to specify an alternate image URL. For example, if you set ImageKey to ImageUrl1, ASP.NET will render the image specified by the <ImageUrl1> element in the randomly selected advertisement, instead of the image specified by the default <ImageUrl> element. This gives you the flexibility to create mobile pages that support multiple different devices, each of which may require a different image format, by adding multiple custom image URLs.

public class 

AdRotator : MobileControl { // Public Constructors public

AdRotator ( ); // Public Instance Properties public string

AdvertisementFile {set; get; } public string

ImageKey {set; get; } public string

KeywordFilter {set; get; } public string

NavigateUrlKey {set; get; } // Protected Instance Methods protected virtual AdRotator

CreateWebAdRotator ( ); protected virtual void

OnAdCreated (System.Web.UI.WebControls.AdCreatedEventArgs

e ); protected override void

Render (System.Web.UI.HtmlTextWriter

writer ); // overrides MobileControl // Events public event AdCreatedEventHandler

AdCreated ; }

Hierarchy

System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) MobileControl(System.Web.UI.IAttributeAccessor) AdRotator