RadzenTextBox Class

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

Implements

IComponent

IHandleEvent

IHandleAfterRender

IRadzenFormComponent

Inherited Members

FormComponentWithAutoComplete<string>.SetParametersAsync

FormComponentWithAutoComplete<string>.AutoCompleteType

FormComponentWithAutoComplete<string>.AutoCompleteAttribute

FormComponentWithAutoComplete<string>.DefaultAutoCompleteAttribute

FormComponentWithAutoComplete<string>.DefaultAriaAutoCompleteAttribute

FormComponentWithAutoComplete<string>.AriaAutoCompleteAttribute

FormComponent<string>.Dispose

FormComponent<string>.GetValue

FormComponent<string>.OnContextMenu

FormComponent<string>.GetClassList

FormComponent<string>.FocusAsync

FormComponent<string>.Name

FormComponent<string>.TabIndex

FormComponent<string>.Placeholder

FormComponent<string>.Disabled

FormComponent<string>.EditContext

FormComponent<string>.Form

FormComponent<string>.ValueChanged

FormComponent<string>.HasValue

FormComponent<string>.IsBound

FormComponent<string>.Value

FormComponent<string>.Change

FormComponent<string>.FieldIdentifier

FormComponent<string>.ValueExpression

FormComponent<string>.FormFieldContext

FormComponent<string>.CurrentPlaceholder

FormComponent<string>._value

RadzenComponent.OnMouseEnter

RadzenComponent.OnMouseLeave

RadzenComponent.GetCssClass

RadzenComponent.Debounce

RadzenComponent.OnInitialized

RadzenComponent.OnAfterRenderAsync

RadzenComponent.RaiseContextMenu

RadzenComponent.RaiseMouseEnter

RadzenComponent.AddContextMenu

RadzenComponent.RaiseMouseLeave

RadzenComponent.OnBecameInvisible

RadzenComponent.Attributes

RadzenComponent.Element

RadzenComponent.MouseEnter

RadzenComponent.MouseLeave

RadzenComponent.ContextMenu

RadzenComponent.Culture

RadzenComponent.DefaultCulture

RadzenComponent.Style

RadzenComponent.Visible

RadzenComponent.UniqueID

RadzenComponent.JSRuntime

RadzenComponent.IsJSRuntimeAvailable

RadzenComponent.Reference

RadzenComponent.CurrentStyle

ComponentBase.OnInitializedAsync

ComponentBase.OnParametersSet

ComponentBase.OnParametersSetAsync

ComponentBase.StateHasChanged

ComponentBase.ShouldRender

ComponentBase.OnAfterRender

ComponentBase.InvokeAsync

ComponentBase.DispatchExceptionAsync

ComponentBase.RendererInfo

ComponentBase.Assets

ComponentBase.AssignedRenderMode

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenTextBox : FormComponentWithAutoComplete<string>, IComponent, IHandleEvent, IHandleAfterRender, 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

RadzenTextBoxlink

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()

Properties

Immediatelink

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
public bool Immediate { get; set; }
Property Value
Type Description
boolGets 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.

MaxLengthlink

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
public long? MaxLength { get; set; }
Property Value
Type Description
long?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.

ReadOnlylink

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
public bool ReadOnly { get; set; }
Property Value
Type Description
boolGets 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.

Trimlink

Gets or sets whether to automatically remove leading and trailing whitespace from the value. When enabled, whitespace is trimmed when the value changes.

Declaration
public bool Trim { get; set; }
Property Value
Type Description
boolGets or sets whether to automatically remove leading and trailing whitespace from the value. When enabled, whitespace is trimmed when the value changes.

Methods

BuildRenderTreelink

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder __builder

GetComponentCssClasslink

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

GetIdlink

Declaration
protected override string GetId()
Returns
Type Description
string

OnChangelink

Handles the change event of the underlying HTML input element. Applies trimming if enabled and notifies the edit context and change listeners.

Declaration
protected virtual Task OnChange(ChangeEventArgs args)
Parameters
Type Name Description
ChangeEventArgs args The change event arguments containing the new value.
Returns
Type Description
TaskA task representing the asynchronous operation.

SetValuelink

Handles the set binding of the underlying HTML input element. Applies trimming if enabled and notifies the edit context and change listeners.

Declaration
protected virtual Task SetValue(string value)
Parameters
Type Name Description
string value string containing the new value.
Returns
Type Description
TaskA task representing the asynchronous operation.
An error has occurred. This app may no longer respond until reloaded. Reload 🗙