IHtmlHelper<TModel>.DisplayFor(Expression<Func<TModel,TResult>>, String, String, Object) IHtmlHelper<TModel>.DisplayFor(Expression<Func<TModel,TResult>>, String, String, Object) IHtmlHelper<TModel>.DisplayFor(Expression<Func<TModel,TResult>>, String, String, Object) Method

Definition

Returns HTML markup for the expression, using a display template, specified HTML field name, and additional view data. The template is found using the templateName or the expression's ModelMetadata.

public Microsoft.AspNetCore.Html.IHtmlContent DisplayFor<TResult> (System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, string templateName, string htmlFieldName, object additionalViewData);
abstract member DisplayFor : System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string * string * obj -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function DisplayFor(Of TResult) (expression As Expression(Of Func(Of TModel, TResult)), templateName As String, htmlFieldName As String, additionalViewData As Object) As IHtmlContent

Type Parameters

TResult

The type of the expression result.

Parameters

expression
Expression<Func<TModel,TResult>>

An expression to be evaluated against the current model.

templateName
String String String

The name of the template used to create the HTML markup.

htmlFieldName
String String String

A String used to disambiguate the names of HTML elements that are created for properties that have the same name.

additionalViewData
Object Object Object

An anonymous Object or IDictionary<TKey,TValue> that can contain additional view data that will be merged into the ViewDataDictionary<TModel> instance created for the template.

Returns

A new IHtmlContent containing the created HTML.

Remarks

For example the default Object display template includes markup for each property in the expression result.

Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on case-sensitive file systems.

Applies to