TextBox
Description
This component represents a text input field in Blazor using the Gap.Blazor.TextBox
model. It supports both single-line and multi-line input, password masking, scroll bar configuration, and selection tracking. It uses Telerik’s TextBox
and TextArea
components and integrates JavaScript interop for advanced selection handling.
Usage
Properties
textBox: Instance of the
Gap.Blazor.TextBox
model.Multiline: Determines whether to render a
TextArea
orTextBox
.PasswordChar: If set, masks input as a password.
ScrollBars: Controls vertical scroll behavior (
None
,Horizontal
).SelectionStart / SelectionLength: Used for tracking and setting text selection.
TextAlign: Controls horizontal text alignment.
ReadOnly: Indicates if the input is editable.
Methods
OnInitialized(): Subscribes to
TextAlignChanged
to update alignment dynamically.Focus(): Focuses the input and applies selection range.
ApplyTextBoxSelection(): Uses JS interop to set selection range.
HandleSelectionChange(start, end): Updates the model when selection changes.
valueChange(string): Updates the model’s text value unless a keypress was already handled.
GetPassword(): Returns
true
ifPasswordChar
is set.GetScrollBarClass(): Returns CSS class based on scroll bar configuration.
GetBorderCss(): Returns border style based on model dimensions.
JavaScript Integration
applyTextBoxSelection: Sets the selection range in the input.
addSelectionChangeListeners: Tracks selection changes and deletion keys.
Dynamic Rendering
TelerikTextBox / TelerikTextArea: Rendered based on
Multiline
.CSS Styling: Dynamically applies border, alignment, and scroll behavior.
JS Interop: Enables advanced selection tracking and manipulation.
Events
TextAlignChanged
SelectionChange (via JS interop)
OnBlur
ValueChanged
Last updated