Dela via


HtmlHelper<TModel>.DisplayFor<TResult> Method

Definition

Returns HTML markup for the expression, using a display template, specified HTML field name, and additional view data. The template name is taken from the templateName or the expression’s TemplateHint. If the template file is not found, a default template will be used.

public:
generic <typename TResult>
 virtual Microsoft::AspNetCore::Html::IHtmlContent ^ DisplayFor(System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::String ^ templateName, System::String ^ htmlFieldName, System::Object ^ additionalViewData);
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
override this.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

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

htmlFieldName
String

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

additionalViewData
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.

Implements

Applies to