Class ContentContext

Keeps track of the current context during rendering. This is used e.g. to output edit attributes for correct properties.

Inheritance
System.Object
ContentContext
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.Mvc
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
public static class ContentContext
Remarks

In case rendering is done through helper method PropertyFor then this is taken care of automatically.

Fields

ContentContextKey

Marker to indicate the text which is stored in httpContext.Items.

Declaration
public const string ContentContextKey = "Epi:ContentContext"
Field Value
Type Description
System.String

Methods

PopCurrentContent(RequestContext, ContentReference)

Pops the current content rendered from context. This is needed when rendering a content area since then the current rendered might differ from the routed content. So this method should be used in combination with PushCurrentContent(RequestContext, ContentReference).

Declaration
public static void PopCurrentContent(RequestContext requestContext, ContentReference contentLink)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

ContentReference contentLink

The content link.

Remarks

PopCurrentProperty(RequestContext)

Pops the current property from context. This should used in combination with PushCurrentProperty(RequestContext, String) and called when the property is done rendered.

Declaration
public static void PopCurrentProperty(RequestContext requestContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

PushCurrentContent(RequestContext, ContentReference)

Pushes the current content rendered to context. This is needed when rendering a content area since then the current rendered might differ from the routed content.

Declaration
public static void PushCurrentContent(RequestContext requestContext, ContentReference contentLink)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

ContentReference contentLink

The content link.

Remarks

PushCurrentProperty(RequestContext, String)

Adds to context that the property with given name is currently rendered.

Declaration
public static void PushCurrentProperty(RequestContext requestContext, string propertyName)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

System.String propertyName

Name of the property.

ShouldRenderEditAttributes(RequestContext, String, IContentLoader)

This method can be used to determine if edit attributes should be added when rendering a property.

Declaration
public static bool ShouldRenderEditAttributes(RequestContext requestContext, string propertyName, IContentLoader contentLoader)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

System.String propertyName

Name of the property.

IContentLoader contentLoader

The content loader.

Returns
Type Description
System.Boolean
Remarks

This method requires that the other push, pop methods on the context is used.