Class SfNumericTextBox<TValue>
The NumericTextBox is used to get the number inputs from the user. The input values can be incremented or decremented by a predefined step value.
Inherited Members
Namespace: Syncfusion.Blazor.Inputs
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfNumericTextBox<TValue> : SfInputTextBase<TValue>
Type Parameters
Name | Description |
---|---|
TValue | Specifies the type of SfNumericTextBox. |
Constructors
SfNumericTextBox()
Declaration
public SfNumericTextBox()
Properties
BaseFloatLabelType
Declaration
protected override FloatLabelType BaseFloatLabelType { get; set; }
Property Value
Type |
---|
FloatLabelType |
Overrides
BaseHtmlAttributes
Declaration
protected override Dictionary<string, object> BaseHtmlAttributes { get; set; }
Property Value
Type |
---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
Overrides
BaseInputAttributes
Declaration
protected override Dictionary<string, object> BaseInputAttributes { get; set; }
Property Value
Type |
---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
Overrides
BaseIsReadOnlyInput
Declaration
protected override bool BaseIsReadOnlyInput { get; set; }
Property Value
Type |
---|
System.Boolean |
Overrides
BasePlaceholder
Declaration
protected override string BasePlaceholder { get; set; }
Property Value
Type |
---|
System.String |
Overrides
BaseReadonly
Declaration
protected override bool BaseReadonly { get; set; }
Property Value
Type |
---|
System.Boolean |
Overrides
BaseShowClearButton
Declaration
protected override bool BaseShowClearButton { get; set; }
Property Value
Type |
---|
System.Boolean |
Overrides
BaseTabIndex
Declaration
protected override int BaseTabIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
Overrides
BaseWidth
Declaration
protected override string BaseWidth { get; set; }
Property Value
Type |
---|
System.String |
Overrides
Currency
Gets or sets the currency code to use in currency formatting. Possible values are the ISO 4217 currency codes, such as USD
for the US dollar and EUR
for the euro.
Declaration
public string Currency { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value representing the currency code. |
Decimals
Gets or sets the number of decimal places to display for numeric values.
Declaration
public Nullable<int> Decimals { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int32> | An integer value representing the number of decimal places. Use |
FloatLabelType
Gets or sets the floating label behavior of the SfNumericTextBox<TValue>. The Placeholder text act as a lable.
Declaration
public FloatLabelType FloatLabelType { get; set; }
Property Value
Type | Description |
---|---|
FloatLabelType | One of the FloatLabelType enumeration. The default value is Never |
Remarks
If the FloatLabelType
is Never
, the placeholder text does not float as a label.
If the FloatLabelType
is Auto
, the placeholder text will float above the Numeric TextBox component as a label after focusing it.
If the FloatLabelType
is Always
, the placeholder text is displayed as a label above the Numeric TextBox component.
Examples
In the following code example, set the float lable as Auto
.
<SfNumericTextBox TValue="int?" Placeholder="Enter the value" FloatLabelType="FloatLabelType.Auto">
</SfNumericTextBox>
Format
Gets or sets the format string used to display numeric values.
Declaration
public string Format { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string value representing the format pattern. The default value is |
Remarks
You can customize the format string according to your requirements. The format string follows the standard format specifiers used in .NET formatting. For example, n3
would display a number with three decimal places.
Examples
<SfNumericTextBox TValue="decimal?" Placeholder="Enter the value" Format="n3" >
</SfNumericTextBox>
HtmlAttributes
Gets or sets a collection of additional attributes such as styles, class, and more that will be applied to the SfNumericTextBox<TValue> component.
Declaration
public Dictionary<string, object> HtmlAttributes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | The value as dictionary collection.The default value is |
Remarks
If you configured both property and equivalent html attributes, then the component considers the property value.
Examples
<SfNumericTextBox TValue="int?" HtmlAttributes="@CustomAttribute">
</SfNumericTextBox>
@code{
Dictionary<string, object> CustomAttribute = new Dictionary<string, object>()
{
{ "title", "Please enter the unit" }
};
}
InputAttributes
Gets or sets a collection of additional inputs attributes such as disabled, value, and more that will be applied to the TextBox component.
Declaration
public Dictionary<string, object> InputAttributes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | The value as dictionary collection.The default value is |
Remarks
Additional attributes can be added by specifying as inline attributes or by specifying @attributes
directive.
If you configured both property and equivalent html attributes, then the component considers the property value.
Examples
<SfNumericTextBox TValue="int?" Placeholder="Enter the PIN" @attributes="@CustomAttribute">
</SfNumericTextBox>
@code{
Dictionary<string, object> CustomAttribute = new Dictionary<string, object>()
{
{ "maxlength", "4" }
};
}
Max
Gets or sets the maximum allowable value for the input.
Declaration
public TValue Max { get; set; }
Property Value
Type | Description |
---|---|
TValue | The maximum allowable value for the input. The default value is determined by the maximum possible value for the data type. |
Examples
<SfNumericTextBox TValue="int?" Placeholder="Enter the value" Max=10 >
</SfNumericTextBox>
Min
Gets or sets the minimum allowable value for the input.
Declaration
public TValue Min { get; set; }
Property Value
Type | Description |
---|---|
TValue | The minimum allowable value for the input. The default value is determined by the minimum possible value for the data type. |
Examples
<SfNumericTextBox TValue="int?" Placeholder="Enter the value" Min=5 >
</SfNumericTextBox>
Placeholder
Gets or sets the text that is displayed when the SfNumericTextBox<TValue> has no value and remove on the focus.
Declaration
public string Placeholder { get; set; }
Property Value
Type | Description |
---|---|
System.String | The text that is displayed when the TextBox has no value. The default value is |
Remarks
The property depends on the FloatLabelType property, The placeholder text acts as a label.
Readonly
Gets or sets the boolean value whether the SfNumericTextBox<TValue> allows the user to change the text.
Declaration
public bool Readonly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ShowClearButton
Get or sets a value that indicates whether the clear button is displayed in SfNumericTextBox<TValue> component.
Declaration
public bool ShowClearButton { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ShowSpinButton
Gets or sets a value indicating whether to display spin buttons for incrementing and decrementing the numeric value.
Declaration
public bool ShowSpinButton { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Step
Gets or sets the increment or decrement value for changing the numeric value.
Declaration
public TValue Step { get; set; }
Property Value
Type | Description |
---|---|
TValue | The step value that determines how much the numeric value changes when interacting with the component. |
Examples
<SfNumericTextBox TValue="int?" Placeholder="Enter the value" Step=5 >
</SfNumericTextBox>
StrictMode
Gets or sets a value indicating whether the component operates in strict mode for value validation.
Declaration
public bool StrictMode { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
TabIndex
Gets or sets the tab order of the SfNumericTextBox<TValue> component.
Declaration
public int TabIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | An integer value representing the tab index of the component. |
ValidateDecimalOnType
Gets or sets a value indicating whether to perform decimal validation during typing.
Declaration
public bool ValidateDecimalOnType { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Width
Gets or sets the width of the SfNumericTextBox<TValue> component.
Declaration
public string Width { get; set; }
Property Value
Type | Description |
---|---|
System.String | The preferred width in pixels or percentage value. The default value is |
Examples
<SfNumericTextBox TValue="int?" Width="200px">
</SfNumericTextBox>
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
ChangeHandler(ChangeEventArgs)
Declaration
protected override Task ChangeHandler(ChangeEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.ChangeEventArgs | args |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
DecrementAsync(TValue)
Decrements the value asynchronously by the specified step.
Declaration
public Task DecrementAsync(TValue step)
Parameters
Type | Name | Description |
---|---|---|
TValue | step | The step value by which to decrement the current value. If its not given then numeric value will be decremented based on the Step property value. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
FocusAsync()
Sets the focus to the NumericTextBox component for interaction.
Declaration
public Task FocusAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
FocusHandler(FocusEventArgs)
Declaration
protected override Task FocusHandler(FocusEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Web.FocusEventArgs | args |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
FocusOutAsync()
Remove the focus from the NumericTextBox component, if the component is in focus state.
Declaration
public Task FocusOutAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
FocusOutHandler(FocusEventArgs)
Declaration
protected override Task FocusOutHandler(FocusEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Web.FocusEventArgs | args |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
FormatValue(String)
Declaration
protected override TValue FormatValue(string genericValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | genericValue |
Returns
Type |
---|
TValue |
Overrides
FormatValueAsString(TValue)
Declaration
protected override string FormatValueAsString(TValue formatValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | formatValue |
Returns
Type |
---|
System.String |
Overrides
GetFormattedText()
Gets the formatted text representation of the current value.
Declaration
public string GetFormattedText()
Returns
Type | Description |
---|---|
System.String | The formatted text representation of the current value. |
GetPersistDataAsync()
Gets the properties to be maintained in the persisted state.
Declaration
public Task<string> GetPersistDataAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A System.Threading.Tasks.Task representing the asynchronous operation. |
IncrementAsync(TValue)
Increments the NumericTextBox value with the specified step value.
Specifies the value used to increment the NumericTextBox value.If its not given then numeric value will be incremented based on the Step property value.Declaration
public Task IncrementAsync(TValue step)
Parameters
Type | Name | Description |
---|---|---|
TValue | step |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |