November Happy Hour will be moved to Thursday December 5th.

Class DisplayChannel

Base class for display channel implementations. A display channel can be used to control which render templates that should be used for a request.

Inheritance
System.Object
DisplayChannel
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Web
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public abstract class DisplayChannel
Examples
  The following example shows a simple channel implemented for WebForms that is active for mobile request.
    public class MobileDisplayChannel : DisplayChannel
{
public override bool IsActive(HttpContextBase context)
{
return context.Request.Browser.IsMobileDevice;
}

public override string ChannelName
{
get { return RenderingTags.Mobile; }
}
}
        The following example shows the registration of a simple channel for MVC that is active for mobile request.
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
context.Locate.DisplayChannelService()
    .RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile)
{
    ContextCondition = (r) => r.Request.Browser.IsMobileDevice
});
}

Constructors

DisplayChannel()

Declaration
protected DisplayChannel()

Properties

ChannelName

Gets the name of the channel.

Declaration
public abstract string ChannelName { get; }
Property Value
Type Description
System.String

The name of the channel.

Remarks

When a DisplayChannel is active then when resolving which TemplateModel (e.g. an page or user control) that should be used to render a request, models where ChannelName have a matching entry in Tags will be prefered.

DisplayName

Gets the name of this DisplayChannel localized to the current language. If no localized name exist ChannelName will be returned.

Declaration
public virtual string DisplayName { get; }
Property Value
Type Description
System.String
Remarks

To localize the DisplayChannel name it should be located at the language path "/displaychannels/displaychannel[@name='ChannelName']/name", where ChannelName matches the ChannelName of the DisplayChannel.

LocalizationService

Gets or sets the localization service to use.

Declaration
public virtual LocalizationService LocalizationService { get; set; }
Property Value
Type Description
LocalizationService

The localization service.

Remarks

By default it will use Current.

NameLocalizationFormat

Gets the name localization format.

Declaration
protected virtual string NameLocalizationFormat { get; }
Property Value
Type Description
System.String
Remarks

The format that is used when localizing the DisplayName.

ResolutionId

Gets the resolution.

Declaration
public virtual string ResolutionId { get; }
Property Value
Type Description
System.String
Remarks

Default value is null meaning channel has no preferred resolution.

Methods

IsActive(HttpContextBase)

Determines whether the specified channel is active given the specified context.

Declaration
public abstract bool IsActive(HttpContextBase context)
Parameters
Type Name Description
System.Web.HttpContextBase context

The context.

Returns
Type Description
System.Boolean

true if the specified channel is active; otherwise, false.

Extension Methods