Table of Contents

Class InputComponent<T>

Namespace
Material.Blazor.Internal
Assembly
Material.Blazor.dll

This is like InputBase from Microsoft.AspNetCore.Components.Forms, except that it treats [CascadingParameter] EditContext as optional.

public abstract class InputComponent<T> : ComponentFoundation, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

Type Parameters

T
Inheritance
InputComponent<T>
Implements
Derived
Inherited Members

Constructors

InputComponent()

protected InputComponent()

Properties

ComponentValueAsString

Gets or sets the current value of the input, represented as a string.

protected string ComponentValueAsString { get; set; }

Property Value

string

EditContext

Gets the associated EditContext.

protected EditContext EditContext { get; }

Property Value

EditContext

FieldClass

Gets a string that indicates the status of the field being edited. This will include some combination of "modified", "valid", or "invalid", depending on the status of the field.

protected string FieldClass { get; }

Property Value

string

FieldIdentifier

Gets the FieldIdentifier for the bound value.

protected FieldIdentifier FieldIdentifier { get; }

Property Value

FieldIdentifier

Value

Gets or sets the value of the input. This should be used with two-way binding.

[Parameter]
public T Value { get; set; }

Property Value

T

Examples

@bind-Value="@model.PropertyName"

ValueChanged

Gets or sets a callback that updates the bound value.

[Parameter]
public EventCallback<T> ValueChanged { get; set; }

Property Value

EventCallback<T>

ValueExpression

Gets or sets an expression that identifies the bound value.

[Parameter]
public Expression<Func<T>> ValueExpression { get; set; }

Property Value

Expression<Func<T>>

Methods

FormatValueToString(T)

Formats the value as a string. Derived classes can override this to determine the formating used for ComponentValueAsString.

protected virtual string FormatValueToString(T value)

Parameters

value T

The value to format.

Returns

string

A string representation of the value.

OnInitializedAsync()

protected override Task OnInitializedAsync()

Returns

Task

OnParametersSetAsync()

When overriding this, call await base.OnParametersSetAsync(); before any user code unless there is a very good reason not to.

protected override Task OnParametersSetAsync()

Returns

Task

SetParametersAsync(ParameterView)

Sets parameters supplied by the component's parent in the render tree.

public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters ParameterView

The parameters.

Returns

Task

A Task that completes when the component has finished updating and rendering itself.

Remarks

Parameters are passed when SetParametersAsync(ParameterView) is called. It is not required that the caller supply a parameter value for all of the parameters that are logically understood by the component.

The default implementation of SetParametersAsync(ParameterView) will set the value of each property decorated with ParameterAttribute or CascadingParameterAttribute that has a corresponding value in the ParameterView. Parameters that do not have a corresponding value will be unchanged.

ShouldRender()

Material.Blazor components descending from MdcInputComponentBase must not override ShouldRender().

protected override sealed bool ShouldRender()

Returns

bool

TryParseValueFromString(string, out T, out string)

Parses a string to create an instance of T. Derived classes can override this to change how ComponentValueAsString interprets incoming values.

protected virtual bool TryParseValueFromString(string value, out T result, out string validationErrorMessage)

Parameters

value string

The string value to be parsed.

result T

An instance of T.

validationErrorMessage string

If the value could not be parsed, provides a validation error message.

Returns

bool

True if the value could be parsed; otherwise false.