Class RadzenTextBox
A single-line text input component that supports data binding, validation, and various input behaviors. RadzenTextBox provides a styled text input with support for placeholders, autocomplete, immediate updates, and string trimming. Supports two-way data binding via @bind-Value and form validation when used within Radzen forms. Can be configured for immediate value updates as the user types or deferred updates on blur/change. Use Trim to automatically remove whitespace, and MaxLength to limit input length.
Inheritance
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenTextBox : FormComponentWithAutoComplete<string>, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormComponent
Examples
Basic usage with two-way binding:
<RadzenTextBox @bind-Value=@username Placeholder="Enter username" />
With immediate updates and trimming:
<RadzenTextBox @bind-Value=@value Immediate="true" Trim="true" MaxLength="50" />
Read-only text box:
<RadzenTextBox Value=@displayValue ReadOnly="true" />
Constructors
RadzenTextBox()
A single-line text input component that supports data binding, validation, and various input behaviors. RadzenTextBox provides a styled text input with support for placeholders, autocomplete, immediate updates, and string trimming. Supports two-way data binding via @bind-Value and form validation when used within Radzen forms. Can be configured for immediate value updates as the user types or deferred updates on blur/change. Use Trim to automatically remove whitespace, and MaxLength to limit input length.
Declaration
public RadzenTextBox()
Examples
Basic usage with two-way binding:
<RadzenTextBox @bind-Value=@username Placeholder="Enter username" />
With immediate updates and trimming:
<RadzenTextBox @bind-Value=@value Immediate="true" Trim="true" MaxLength="50" />
Read-only text box:
<RadzenTextBox Value=@displayValue ReadOnly="true" />
Properties
Immediate
Gets or sets whether the component should update the bound value immediately as the user types (oninput event), rather than waiting for the input to lose focus (onchange event). This enables real-time value updates but may trigger more frequent change events.
Declaration
[Parameter]
public bool Immediate { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
MaxLength
Gets or sets the maximum number of characters that can be entered in the text box. When set, the browser will prevent users from typing beyond this limit.
Declaration
[Parameter]
public long? MaxLength { get; set; }
Property Value
| Type | Description |
|---|---|
| long? | The maximum character length, or null for no limit. Default is null. |
ReadOnly
Gets or sets whether the text box is read-only and cannot be edited by the user. When true, the text box displays the value but prevents user input while still allowing selection and copying.
Declaration
[Parameter]
public bool ReadOnly { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Trim
Gets or sets whether to automatically remove leading and trailing whitespace from the value. When enabled, whitespace is trimmed when the value changes.
Declaration
[Parameter]
public bool Trim { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
BuildRenderTree(RenderTreeBuilder)
A single-line text input component that supports data binding, validation, and various input behaviors. RadzenTextBox provides a styled text input with support for placeholders, autocomplete, immediate updates, and string trimming. Supports two-way data binding via @bind-Value and form validation when used within Radzen forms. Can be configured for immediate value updates as the user types or deferred updates on blur/change. Use Trim to automatically remove whitespace, and MaxLength to limit input length.
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected override string GetComponentCssClass()
Returns
| Type | Description |
|---|---|
| string |
Overrides
GetId()
Gets the unique identifier.
Declaration
protected override string GetId()
Returns
| Type | Description |
|---|---|
| string | Returns the |
Overrides
OnChange(ChangeEventArgs)
Handles the change event of the underlying HTML input element. Applies trimming if enabled and notifies the edit context and change listeners.
Declaration
protected Task OnChange(ChangeEventArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| ChangeEventArgs | args | The change event arguments containing the new value. |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation. |