How do you build a custom input component by inheriting from InputBase<T>?
Last updated
Deriving from
InputBase<T>gives you two-way binding (CurrentValue/CurrentValueAsString),EditContextnotification, and validation CSS classes for free.You must override
TryParseValueFromStringto convert user input intoT(returning an error message on failure) and render markup bound toCurrentValueAsString.Optionally override
FormatValueAsStringto control how the value is displayed.
- https://blazor-university.com/forms/descending-from-inputbase/
- https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/binding?view=aspnetcore-10.0
- https://chrissainty.com/creating-bespoke-input-components-for-blazor-from-scratch/
- https://github.com/dotnet/aspnetcore/issues/58869
- https://chrissainty.com/building-custom-input-components-for-blazor-using-inputbase/
- https://www.meziantou.net/creating-a-inputselect-component-for-enumerations-in-blazor.htm