Class NumericTextBoxEvents<TValue>
Provides event callback definitions for the SfNumericTextBox<TValue> component. This class contains various event handlers that can be invoked during different lifecycle stages and user interactions with the NumericTextBox.
Inherited Members
Namespace: Syncfusion.Blazor.Inputs
Assembly: Syncfusion.Blazor.dll
Syntax
public class NumericTextBoxEvents<TValue> : SfInputTextBase<TValue>
Type Parameters
Name | Description |
---|---|
TValue | Specifies the type of value that the SfNumericTextBox<TValue> component handles. |
Remarks
The NumericTextBoxEvents class allows developers to handle various events such as focus, blur, value changes, and component lifecycle events. This event container is used as a child component within the SfNumericTextBox<TValue> to define event callbacks.
Examples
Example of using NumericTextBoxEvents with event callbacks:
<SfNumericTextBox TValue="int?" Placeholder="Enter a number">
<NumericTextBoxEvents TValue="int?"
ValueChange="@OnValueChange"
Focus="@OnFocus"
Blur="@OnBlur"
Created="@OnCreated" />
</SfNumericTextBox>
@code {
private void OnValueChange(ChangeEventArgs<int?> args)
{
// Handle value change
}
private void OnFocus(NumericFocusEventArgs<int?> args)
{
// Handle focus event
}
private void OnBlur(NumericBlurEventArgs<int?> args)
{
// Handle blur event
}
private void OnCreated(object args)
{
// Handle component creation
}
}
Constructors
NumericTextBoxEvents()
Declaration
public NumericTextBoxEvents()
Properties
BaseParent
Gets or sets the parent SfNumericTextBox<TValue> component instance that contains this event container.
Declaration
protected SfNumericTextBox<TValue> BaseParent { get; set; }
Property Value
Type | Description |
---|---|
SfNumericTextBox<TValue> | A reference to the parent SfNumericTextBox<TValue> component. The default value is |
Remarks
This property is automatically set by the Blazor framework through cascading parameters when the NumericTextBoxEvents component is used as a child of SfNumericTextBox<TValue>. It establishes the connection between the event container and its parent NumericTextBox component.
Blur
Gets or sets an event callback that is invoked when the SfNumericTextBox<TValue> component loses focus.
Declaration
public EventCallback<NumericBlurEventArgs<TValue>> Blur { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<NumericBlurEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives NumericBlurEventArgs<T> containing information about the blur event. |
Remarks
The Blur event is triggered when the NumericTextBox loses focus, typically when the user clicks outside the component or navigates to another control using the Tab key. You can use this event to perform validation, save data, or update the UI based on the component losing focus.
Examples
Example of handling the Blur event:
<SfNumericTextBox TValue="int?">
<NumericTextBoxEvents TValue="int?" Blur="@OnBlur" />
</SfNumericTextBox>
@code {
private void OnBlur(NumericBlurEventArgs<int?> args)
{
// Perform validation or other actions when component loses focus
Console.WriteLine($"NumericTextBox lost focus. Current value: {args.Value}");
}
}
Created
Gets or sets an event callback that is invoked when the SfNumericTextBox<TValue> component is created and fully initialized.
Declaration
public EventCallback<object> Created { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback<> that receives an System.Object parameter when the component creation is complete. |
Remarks
The Created event is triggered after the NumericTextBox component has been fully rendered and initialized on the client-side. This event is useful for performing initialization tasks, setting up additional configurations, or integrating with third-party libraries that require the component to be fully rendered.
Examples
Example of handling the Created event:
<SfNumericTextBox TValue="decimal?">
<NumericTextBoxEvents TValue="decimal?" Created="@OnCreated" />
</SfNumericTextBox>
@code {
private void OnCreated(object args)
{
// Component is fully created and rendered
Console.WriteLine("NumericTextBox component has been created successfully");
}
}
Destroyed
Gets or sets an event callback that is invoked when the SfNumericTextBox<TValue> component is destroyed or disposed.
Declaration
public EventCallback<object> Destroyed { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback<> that receives an System.Object parameter when the component destruction occurs. |
Remarks
The Destroyed event is triggered when the NumericTextBox component is being removed from the DOM or disposed of. This event is useful for performing cleanup tasks, removing event listeners, or disposing of resources that were allocated during the component's lifecycle.
Examples
Example of handling the Destroyed event:
<SfNumericTextBox TValue="double?">
<NumericTextBoxEvents TValue="double?" Destroyed="@OnDestroyed" />
</SfNumericTextBox>
@code {
private void OnDestroyed(object args)
{
// Perform cleanup when component is destroyed
Console.WriteLine("NumericTextBox component has been destroyed");
}
}
Focus
Gets or sets an event callback that is invoked when the SfNumericTextBox<TValue> component receives focus.
Declaration
public EventCallback<NumericFocusEventArgs<TValue>> Focus { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<NumericFocusEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives NumericFocusEventArgs<T> containing information about the focus event. |
Remarks
The Focus event is triggered when the NumericTextBox receives focus, typically when the user clicks on the component or navigates to it using the Tab key. You can use this event to highlight the component, show additional UI elements, or perform initialization tasks that should occur when the component becomes active.
Examples
Example of handling the Focus event:
<SfNumericTextBox TValue="float?">
<NumericTextBoxEvents TValue="float?" Focus="@OnFocus" />
</SfNumericTextBox>
@code {
private void OnFocus(NumericFocusEventArgs<float?> args)
{
// Handle focus event
Console.WriteLine($"NumericTextBox received focus. Current value: {args.Value}");
}
}
ValueChange
Gets or sets an event callback that is invoked when the value of the SfNumericTextBox<TValue> component changes.
Declaration
public EventCallback<ChangeEventArgs<TValue>> ValueChange { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ChangeEventArgs<TValue>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives ChangeEventArgs<T> containing the old and new values when the component's value changes. |
Remarks
The ValueChange event is triggered whenever the user modifies the numeric value in the TextBox, either by typing, using the spin buttons, or through programmatic changes. This event provides both the previous and current values, allowing you to track changes and implement custom logic based on value modifications.
Examples
Example of handling the ValueChange event:
<SfNumericTextBox TValue="int?" Placeholder="Enter the value">
<NumericTextBoxEvents TValue="int?" ValueChange="@OnValueChange" />
</SfNumericTextBox>
@code {
private void OnValueChange(ChangeEventArgs<int?> args)
{
var previousValue = args.PreviousValue;
var currentValue = args.Value;
Console.WriteLine($"Value changed from {previousValue} to {currentValue}");
}
}