Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Class PropertyExtensions

Display extensions

Inheritance
System.Object
PropertyExtensions
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
public static class PropertyExtensions

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
[Obsolete("Use PropertyRenderer.CustomSettingsAttributeWriter instead.", false)]
public static 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.

PropertyRenderer

The property renderer

Declaration
public static PropertyRenderer PropertyRenderer { get; set; }
Property Value
Type Description
PropertyRenderer

Methods

BeginEditSection(HtmlHelper, String, String)

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 static MvcHtmlString BeginEditSection(this HtmlHelper helper, string htmlElement, string propertyName)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String htmlElement

The HTML element.

System.String propertyName

The property name.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

Remarks

This should be used together with EndEditSection.

BeginEditSection(HtmlHelper, 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 static MvcHtmlString BeginEditSection(this HtmlHelper helper, string htmlElement, string propertyName, object htmlAttributes)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String htmlElement

The HTML element.

System.String propertyName

The property name.

System.Object htmlAttributes

An anonymus 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.

BeginEditSection<TModel, TResult>(HtmlHelper<TModel>, String, Expression<Func<TModel, TResult>>)

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 static MvcHtmlString BeginEditSection<TModel, TResult>(this HtmlHelper<TModel> helper, string htmlElement, Expression<Func<TModel, TResult>> expression)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> helper

The html helper.

System.String htmlElement

The HTML element.

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

The expression that points out the property to add edit hints for

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

Type Parameters
Name Description
TModel

The type of the model.

TResult

The type of the result.

Remarks

This should be used together with EndEditSection.

BeginEditSection<TModel, TResult>(HtmlHelper<TModel>, String, Expression<Func<TModel, TResult>>, 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 static MvcHtmlString BeginEditSection<TModel, TResult>(this HtmlHelper<TModel> helper, string htmlElement, Expression<Func<TModel, TResult>> expression, object htmlAttributes)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> helper

The html helper.

System.String htmlElement

The HTML element.

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

The expression that points out the property to add edit hints for.

System.Object htmlAttributes

An anonymus object with additional HTML attributes.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

Type Parameters
Name Description
TModel

The type of the model.

TResult

The type of the result.

Remarks

This should be used together with EndEditSection.

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

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

Declaration
public static EditContainer CreateEditElement(this HtmlHelper helper, string epiPropertyKey, string epiPropertyName, string editElementName, string editElementCssClass, Func<string> attributeWriter)
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> attributeWriter

The attribute writer.

Returns
Type Description
EditContainer

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

EditAttributes(HtmlHelper, String)

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

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

The html helper.

System.String propertyName

The property name.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

EditAttributes<TModel, TResult>(HtmlHelper<TModel>, Expression<Func<TModel, TResult>>)

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

Declaration
public static MvcHtmlString EditAttributes<TModel, TResult>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TResult>> expression)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> helper

The html helper.

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

The expression.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

The required attribute to make an html element editable.

Type Parameters
Name Description
TModel

The type of the model.

TResult

The type of the result.

EditContainerClass(HtmlHelper)

Get the default CSS class for edit container.

Declaration
public static MvcHtmlString EditContainerClass(this HtmlHelper helper)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The helper.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

Default CSS class for edit container if in editing mode, otherwise returns empty string.

EditContainerClass(HtmlHelper, String)

Get the CSS class for edit container.

Declaration
public static MvcHtmlString EditContainerClass(this HtmlHelper helper, string editContainerClass)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The helper.

System.String editContainerClass

The custom CSS class for edit container.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

Specified custom CSS class for edit container if in editing mode, otherwise returns empty string.

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(this 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.

FullRefreshPropertiesMetaData(HtmlHelper, String[])

Returns a hidden input element with a data-epi-full-refresh-property-names attribute containing a comma separated list of names of properties that requires a full page refresh when edited.

Declaration
public static MvcHtmlString FullRefreshPropertiesMetaData(this HtmlHelper helper, string[] propertyNames)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper helper

The html helper.

System.String[] propertyNames

The names of the properties that require a full refresh.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

A hidden input with a data-epi-full-refresh-property-names containing the list of propertiy names passed to propertyNames.

FullRefreshPropertiesMetaData<TModel>(HtmlHelper<TModel>)

Returns a hidden input element with a data-epi-full-refresh-property-names attribute containing a comma separated list of names of properties that requires a full page refresh when edited.

Declaration
public static MvcHtmlString FullRefreshPropertiesMetaData<TModel>(this HtmlHelper<TModel> helper)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> helper

The html helper.

Returns
Type Description
System.Web.Mvc.MvcHtmlString

A hidden input with a data-epi-full-refresh-property-names containing the list of property names found in the ViewData.

Type Parameters
Name Description
TModel

PropertyFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>)

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

Declaration
public static MvcHtmlString PropertyFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends..

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

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

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>, Expression<Func<TModel, TValue>>, Object)

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

Declaration
public static MvcHtmlString PropertyFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, object additionalViewData)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends..

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

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

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.

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>, Expression<Func<TModel, TValue>>, String)

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

Declaration
public static MvcHtmlString PropertyFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends..

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

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

System.String templateName

The name of the template that is used to render the object..

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>, Expression<Func<TModel, TValue>>, String, Object)

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

Declaration
public static MvcHtmlString PropertyFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, object additionalViewData)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends..

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

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

System.String templateName

The name of the template that is used to render the object..

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.

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>, Expression<Func<TModel, TValue>>, String, String)

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

Declaration
public static MvcHtmlString PropertyFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldName)
Parameters
Type Name Description
System.Web.Mvc.HtmlHelper<TModel> html

The HTML helper instance that this method extends..

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

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

System.String templateName

The name of the template that is used to render the object.

System.String htmlFieldName

A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the same name.

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>, Expression<Func<TModel, TValue>>, String, String, Object, Object)

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

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

The HTML helper instance that this method extends..

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

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

System.String templateName

The name of the template that is used to render the object.

System.String htmlFieldName

A string that is used to disambiguate the names of HTML input elements that are rendered for properties that have the same 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.

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.