Try our conversational search powered by Generative AI!

Class PropertyRenderer

Property rendering in MVC.

Inheritance
System.Object
PropertyRenderer
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.Html
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
[ServiceConfiguration(typeof(PropertyRenderer))]
public class PropertyRenderer

Constructors

PropertyRenderer()

Initializes a new instance of the PropertyRenderer class.

Declaration
public PropertyRenderer()

Properties

CustomSettingsAttributeWriter

Gets or sets the function to use to output custom settings attribute. Returned value is expected to be in format 'data-epi-property-customsetting=value'.

Declaration
public virtual Func<RouteValueDictionary, string, string> CustomSettingsAttributeWriter { get; set; }
Property Value
Type Description
System.Func<System.Web.Routing.RouteValueDictionary, System.String, System.String>

The custom settings attribute writer.

Methods

BeginEditSection(HtmlHelper, String, String, String, Object)

Writes the required attribute to make an html element editable (when in edit mode).

BeginEditSection/EndEditSection should be used instead of EditAttributes when rendering a block or inside partial views for blocks.

The difference between EditAttributes and BeginEditSection/EndEditSection is that when using BeginEditSection then no other edit hints for nested properties will be written out before EndEditSection is called.

Declaration
public virtual MvcHtmlString BeginEditSection(HtmlHelper helper, string htmlElement, string propertyKey, string propertyName, object htmlAttributes)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String htmlElement

The HTML element.

System.String propertyKey

PageEditing.DataEPiPropertyName

System.String propertyName

The property name.

System.Object htmlAttributes

An anonymous object with additional HTML attributes.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

Remarks

This should be used together with EndEditSection.

CreateEditElement(HtmlHelper, String, String, String, String, Func<String>, Func<String>, TextWriter)

Creates an edit container. The object can create an element in edit mode

Declaration
public virtual EditContainer CreateEditElement(HtmlHelper helper, string epiPropertyKey, string epiPropertyName, string editElementName, string editElementCssClass, Func<string> renderSettingsAttributeWriter, Func<string> editorSettingsAttributeWriter, TextWriter writer)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String epiPropertyKey

Key of the epi property.

System.String epiPropertyName

Name of the epi property.

System.String editElementName

Name of the edit element.

System.String editElementCssClass

The CSS class for edit element.

System.Func<System.String> renderSettingsAttributeWriter

The render settins attribute writer action.

System.Func<System.String> editorSettingsAttributeWriter

The editor settins attribute writer action.

System.IO.TextWriter writer

The writer.

Returns
Type Description
EditContainer

EditContainer object. At dispose, the element end will be written.

CurrentContentContainsProperty<TModel>(HtmlHelper<TModel>, String)

Indicates if a property with the propertyName exists on the current content.

Declaration
protected virtual bool CurrentContentContainsProperty<TModel>(HtmlHelper<TModel> html, string propertyName)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends.

System.String propertyName

The property name.

Returns
Type Description
System.Boolean

True if the current content contains a property with the property name.

Type Parameters
Name Description
TModel

The content type

EditAttributes(HtmlHelper, String, String)

Get the required attribute to make an html element editable. Will return an empty string if not in edit context mode.

Declaration
public virtual MvcHtmlString EditAttributes(HtmlHelper helper, string propertyKey, string propertyName)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String propertyKey

The property key.

System.String propertyName

The property name.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

EndEditSection(HtmlHelper, String)

Marks that the corresponding BeginEditSection is ended.

BeginEditSection/EndEditSection should be used instead of EditAttributes when rendering a block or inside partial views for blocks.

The difference between EditAttributes and BeginEditSection is that when using BeginEditSection then no other edit hints for nested properties will be written out before EndEditSection is called.

Declaration
public static MvcHtmlString EndEditSection(HtmlHelper helper, string htmlElement)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String htmlElement

The HTML element.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

the end element.

Remarks

This should be used together with BeginEditSection and outputs the end element.

GetHtmlForDefaultMode<TModel, TValue>(String, String, String, String, Func<String, MvcHtmlString>)

Returns HTML markup for the property when it's rendered in default mode.

Declaration
protected virtual MvcHtmlString GetHtmlForDefaultMode<TModel, TValue>(string propertyName, string templateName, string elementName, string elementCssClass, Func<string, MvcHtmlString> displayForAction)
Parameters
Type Name Description
System.String propertyName

The property name.

System.String templateName

The name of the template that should be called.

System.String elementName

The surrounded element name.

System.String elementCssClass

The css class element name.

System.Func<System.String, System.Web.Mvc.MvcHtmlString> displayForAction

The displayFor action.

Returns
Type Description
System.Web.Mvc.MvcHtmlString
Type Parameters
Name Description
TModel

The content data type.

TValue

The type of the value.

GetHtmlForEditMode<TModel, TValue>(HtmlHelper<TModel>, String, Object, Func<String, MvcHtmlString>, String, String, String, RouteValueDictionary)

Returns HTML markup for each property in the object that is represented by the Expression expression.

Declaration
protected virtual MvcHtmlString GetHtmlForEditMode<TModel, TValue>(HtmlHelper<TModel> html, string viewModelPropertyName, object editorSettings, Func<string, MvcHtmlString> displayForAction, string templateName, string editElementName, string editElementCssClass, RouteValueDictionary additionalValues)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends.

System.String viewModelPropertyName

The property name.

System.Object editorSettings

Any custom editor settings.

System.Func<System.String, System.Web.Mvc.MvcHtmlString> displayForAction

The The displayFor action.

System.String templateName

The name of the template that should be called.

System.String editElementName

The surrounded element name.

System.String editElementCssClass

The css class element name.

System.Web.Routing.RouteValueDictionary additionalValues

Additional values.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The HTML markup for each property in the object that is represented by the expression.

Type Parameters
Name Description
TModel

The content data type.

TValue

The type of the value.

PropertyFor<TModel, TValue>(HtmlHelper<TModel>, String, Object, Object, Expression<Func<TModel, TValue>>, Func<String, MvcHtmlString>)

Returns HTML markup for each property in the object that is represented by the Expression expression.

Declaration
public virtual MvcHtmlString PropertyFor<TModel, TValue>(HtmlHelper<TModel> html, string viewModelPropertyName, object additionalViewData, object editorSettings, Expression<Func<TModel, TValue>> expression, Func<string, MvcHtmlString> displayForAction)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends.

System.String viewModelPropertyName

The property name.

System.Object additionalViewData

An anonymous object that can contain additional view data that will be merged into the ViewDataDictionary instance that is created for the template.

System.Object editorSettings

Any custom editor settings.

System.Linq.Expressions.Expression<System.Func<TModel, TValue>> expression

An expression that identifies the object that contains the properties to display.

System.Func<System.String, System.Web.Mvc.MvcHtmlString> displayForAction

The The displayFor action.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The HTML markup for each property in the object that is represented by the expression.

Type Parameters
Name Description
TModel

The content data type.

TValue

The type of the value.

Extension Methods