Class BindingViewComponent

Version: 21.x

Provides delayed binding for a Microsoft.AspNetCore.Mvc.ViewComponent.

Inheritance

System.Object

BindingViewComponent

SitecoreComponentViewComponent

Namespace: Sitecore.AspNet.RenderingEngine.Mvc

Assembly: Sitecore.AspNet.RenderingEngine.dll

Syntax
public abstract class BindingViewComponent : ViewComponent

Constructors

BindingViewComponent(IViewModelBinder)

Initializes a new instance of the BindingViewComponent class.

Declaration
protected BindingViewComponent(IViewModelBinder binder)
Parameters
TypeNameDescription
IViewModelBinderbinderThe IViewModelBinder to enable binding.

Properties

Binder

Gets the instance of IViewModelBinder used for binding.

Declaration
protected IViewModelBinder Binder { get; }
Property Value
TypeDescription
IViewModelBinder

Methods

BindView(Type, String)

Returns the specified view bound to the given model type.

Declaration
public virtual Task<IViewComponentResult> BindView(Type modelType, string viewName)
Parameters
TypeNameDescription
System.TypemodelTypeThe model type to be used for binding.
System.StringviewNameThe view to be returned.
Returns
TypeDescription
System.Threading.Tasks.Task

<

Microsoft.AspNetCore.Mvc.IViewComponentResult

>
The Microsoft.AspNetCore.Mvc.IViewComponentResult.

BindView()

Returns the default view using a bound model of TModel.

Declaration

public virtual Task<IViewComponentResult> BindView<TModel>()
    where TModel : class, new()

Returns
TypeDescription
System.Threading.Tasks.Task

<

Microsoft.AspNetCore.Mvc.IViewComponentResult

>
The Microsoft.AspNetCore.Mvc.IViewComponentResult.
Type Parameters
NameDescription
TModelThe model to be bound.

BindView(TModel)

Returns the default view bound to the given model.

Declaration

public virtual Task<IViewComponentResult> BindView<TModel>(TModel model)
    where TModel : class

Parameters
TypeNameDescription
TModelmodelAn instance of TModel to be bound.
Returns
TypeDescription
System.Threading.Tasks.Task

<

Microsoft.AspNetCore.Mvc.IViewComponentResult

>
The Microsoft.AspNetCore.Mvc.IViewComponentResult.
Type Parameters
NameDescription
TModelThe model to be bound.

BindView(String)

Returns the specified view using a bound model of TModel.

Declaration

public virtual Task<IViewComponentResult> BindView<TModel>(string viewName)
    where TModel : class, new()

Parameters
TypeNameDescription
System.StringviewNameThe view to be returned.
Returns
TypeDescription
System.Threading.Tasks.Task

<

Microsoft.AspNetCore.Mvc.IViewComponentResult

>
The Microsoft.AspNetCore.Mvc.IViewComponentResult.
Type Parameters
NameDescription
TModelThe model to be bound.

BindView(String, TModel)

Returns the specified view bound to the given model.

Declaration

public virtual Task<IViewComponentResult> BindView<TModel>(string viewName, TModel model)
    where TModel : class

Parameters
TypeNameDescription
System.StringviewNameThe view to be returned.
TModelmodelAn instance of TModel to be bound.
Returns
TypeDescription
System.Threading.Tasks.Task

<

Microsoft.AspNetCore.Mvc.IViewComponentResult

>
The Microsoft.AspNetCore.Mvc.IViewComponentResult.
Type Parameters
NameDescription
TModelThe model to be bound.
If you have suggestions for improving this article, let us know!