Class InputComponent<T>
This is like InputBase from Microsoft.AspNetCore.Components.Forms, except that it treats [CascadingParameter] EditContext as optional.
Inheritance
Implements
Inherited Members
Namespace: Material.Blazor.Internal
Assembly: Material.Blazor.dll
Syntax
public abstract class InputComponent<T> : ComponentFoundation, IDisposable
Type Parameters
Name | Description |
---|---|
T |
Properties
| Improve this Doc View SourceComponentValueAsString
Gets or sets the current value of the input, represented as a string.
Declaration
protected string ComponentValueAsString { get; set; }
Property Value
Type | Description |
---|---|
String |
EditContext
Gets the associated EditContext.
Declaration
protected EditContext EditContext { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
protected string FieldClass { get; }
Property Value
Type | Description |
---|---|
String |
FieldIdentifier
Gets the FieldIdentifier for the bound value.
Declaration
protected FieldIdentifier FieldIdentifier { get; }
Property Value
Type | Description |
---|---|
FieldIdentifier |
Value
Gets or sets the value of the input. This should be used with two-way binding.
Declaration
public T Value { get; set; }
Property Value
Type | Description |
---|---|
T |
Examples
@bind-Value="@model.PropertyName"
| Improve this Doc View SourceValueChanged
Gets or sets a callback that updates the bound value.
Declaration
public EventCallback<T> ValueChanged { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<T> |
ValueExpression
Gets or sets an expression that identifies the bound value.
Declaration
public Expression<Func<T>> ValueExpression { get; set; }
Property Value
Type | Description |
---|---|
Expression<Func<T>> |
Methods
| Improve this Doc View SourceFormatValueToString(T)
Formats the value as a string. Derived classes can override this to determine the formating used for ComponentValueAsString.
Declaration
protected virtual string FormatValueToString(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to format. |
Returns
Type | Description |
---|---|
String | A string representation of the value. |
OnInitializedAsync()
Declaration
protected override async Task OnInitializedAsync()
Returns
Type | Description |
---|---|
Task |
OnParametersSetAsync()
When overriding this, call await base.OnParametersSetAsync();
before any user code unless there is a very good reason not to.
Declaration
protected override async Task OnParametersSetAsync()
Returns
Type | Description |
---|---|
Task |
Overrides
| Improve this Doc View SourceSetParametersAsync(ParameterView)
Declaration
public override async Task SetParametersAsync(ParameterView parameters)
Parameters
Type | Name | Description |
---|---|---|
ParameterView | parameters |
Returns
Type | Description |
---|---|
Task |
ShouldRender()
Material.Blazor components descending from MdcInputComponentBase must not override ShouldRender().
Declaration
protected sealed override bool ShouldRender()
Returns
Type | Description |
---|---|
Boolean |
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.
Declaration
protected virtual bool TryParseValueFromString(string value, out T result, out string validationErrorMessage)
Parameters
Type | Name | Description |
---|---|---|
String | value | The string value to be parsed. |
T | result | An instance of |
String | validationErrorMessage | If the value could not be parsed, provides a validation error message. |
Returns
Type | Description |
---|---|
Boolean | True if the value could be parsed; otherwise false. |
Events
| Improve this Doc View SourceSetComponentValue
Derived components can use this to get a callback from SetParameters(Async) when the consumer changes
the value. This allows a component to take action with Material Theme js to update the DOM to reflect
the data change visually. An example is a select where the relevant list item needs to be
automatically clicked to get Material Theme to update the value shown in the
<input>
HTML tag.
Declaration
protected event Action SetComponentValue
Event Type
Type | Description |
---|---|
Action |