Class BindingViewComponent

Version: 21.x

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

Inheritance
System.Object
BindingViewComponent
Namespace: Sitecore.AspNet.RenderingEngine.Mvc
Assembly: Sitecore.AspNet.RenderingEngine.dll
Syntax
RequestResponse
public abstract class BindingViewComponent : ViewComponent

Constructors

BindingViewComponent(IViewModelBinder)

Initializes a new instance of the BindingViewComponent class.

Declaration
RequestResponse
protected BindingViewComponent(IViewModelBinder binder)
Parameters
TypeNameDescription
IViewModelBinderbinder

The IViewModelBinder to enable binding.

Properties

Binder

Gets the instance of IViewModelBinder used for binding.

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

Methods

BindView(Type, String)

Returns the specified view bound to the given model type.

Declaration
RequestResponse
public virtual Task<IViewComponentResult> BindView(Type modelType, string viewName)
Parameters
TypeNameDescription
System.TypemodelType

The model type to be used for binding.

System.StringviewName

The view to be returned.

Returns
TypeDescription
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult>

The Microsoft.AspNetCore.Mvc.IViewComponentResult.

BindView<TModel>()

Returns the default view using a bound model of TModel.

Declaration
RequestResponse
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
TModel

The model to be bound.

BindView<TModel>(TModel)

Returns the default view bound to the given model.

Declaration
RequestResponse
public virtual Task<IViewComponentResult> BindView<TModel>(TModel model)
    where TModel : class
Parameters
TypeNameDescription
TModelmodel

An instance of TModel to be bound.

Returns
TypeDescription
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult>

The Microsoft.AspNetCore.Mvc.IViewComponentResult.

Type Parameters
NameDescription
TModel

The model to be bound.

BindView<TModel>(String)

Returns the specified view using a bound model of TModel.

Declaration
RequestResponse
public virtual Task<IViewComponentResult> BindView<TModel>(string viewName)
    where TModel : class, new()
Parameters
TypeNameDescription
System.StringviewName

The view to be returned.

Returns
TypeDescription
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult>

The Microsoft.AspNetCore.Mvc.IViewComponentResult.

Type Parameters
NameDescription
TModel

The model to be bound.

BindView<TModel>(String, TModel)

Returns the specified view bound to the given model.

Declaration
RequestResponse
public virtual Task<IViewComponentResult> BindView<TModel>(string viewName, TModel model)
    where TModel : class
Parameters
TypeNameDescription
System.StringviewName

The view to be returned.

TModelmodel

An instance of TModel to be bound.

Returns
TypeDescription
System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult>

The Microsoft.AspNetCore.Mvc.IViewComponentResult.

Type Parameters
NameDescription
TModel

The model to be bound.

Do you have some feedback for us?

If you have suggestions for improving this article,