Class BindingViewComponent
Provides delayed binding for a Microsoft.AspNetCore.Mvc.ViewComponent.
Namespace: Sitecore.AspNet.RenderingEngine.Mvc
Assembly: Sitecore.AspNet.RenderingEngine.dll
Syntax
public abstract class BindingViewComponent : ViewComponentConstructors
BindingViewComponent(IViewModelBinder)
Initializes a new instance of the BindingViewComponent class.
Declaration
protected BindingViewComponent(IViewModelBinder binder)Parameters
| Type | Name | Description |
|---|---|---|
| IViewModelBinder | binder |
The IViewModelBinder to enable binding. |
Properties
Binder
Gets the instance of IViewModelBinder used for binding.
Declaration
protected IViewModelBinder Binder { get; }Property Value
| Type | Description |
|---|---|
| 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
| Type | Name | Description |
|---|---|---|
| System.Type | modelType |
The model type to be used for binding. |
| System.String | viewName |
The view to be returned. |
Returns
| Type | Description |
|---|---|
| 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
public virtual Task<IViewComponentResult> BindView<TModel>()
where TModel : class, new()Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult> |
The Microsoft.AspNetCore.Mvc.IViewComponentResult. |
Type Parameters
| Name | Description |
|---|---|
| TModel |
The model to be bound. |
BindView<TModel>(TModel)
Returns the default view bound to the given model.
Declaration
public virtual Task<IViewComponentResult> BindView<TModel>(TModel model)
where TModel : classParameters
| Type | Name | Description |
|---|---|---|
| TModel | model |
An instance of |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult> |
The Microsoft.AspNetCore.Mvc.IViewComponentResult. |
Type Parameters
| Name | Description |
|---|---|
| TModel |
The model to be bound. |
BindView<TModel>(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
| Type | Name | Description |
|---|---|---|
| System.String | viewName |
The view to be returned. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult> |
The Microsoft.AspNetCore.Mvc.IViewComponentResult. |
Type Parameters
| Name | Description |
|---|---|
| TModel |
The model to be bound. |
BindView<TModel>(String, TModel)
Returns the specified view bound to the given model.
Declaration
public virtual Task<IViewComponentResult> BindView<TModel>(string viewName, TModel model)
where TModel : classParameters
| Type | Name | Description |
|---|---|---|
| System.String | viewName |
The view to be returned. |
| TModel | model |
An instance of |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Microsoft.AspNetCore.Mvc.IViewComponentResult> |
The Microsoft.AspNetCore.Mvc.IViewComponentResult. |
Type Parameters
| Name | Description |
|---|---|
| TModel |
The model to be bound. |