NumericUpDown
in namespace DotVVM.BusinessPack.Controls
Renders an <input> element with buttons on the side that increase or decrease the value.
Usage & Scenarios
A text field which allows to enter numeric values and to increase or decrease them by the specified step.
Sample 1: Basic Usage
The Value
property represents the numeric value entered in the control.
The MinValue
and MaxValue
specifies the range or values which are allowed in the control.
The Step
property specifies a value to be added or subtracted when the user clicks the Up and Down buttons in the control.
<bp:NumericUpDown Value="{value: Value}"
MinValue="0.5"
MaxValue="5"
Step="0.5" />
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.NumericUpDown.sample1
{
public class ViewModel : DotvvmViewModelBase
{
public double Value { get; set; } = 1.5;
}
}
Sample 2: Changed Event
The Changed
event specifies a command in the viewmodel which is triggered whenever the value is changed.
<bp:NumericUpDown Value="{value: Value}"
Changed="{command: ValueChanged()}" />
<p>Numeric value has changed {{value: ChangeCount}} times.</p>
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.NumericUpDown.sample2
{
public class ViewModel : DotvvmViewModelBase
{
public double Value { get; set; }
public int ChangeCount { get; set; }
public void ValueChanged()
{
ChangeCount++;
}
}
}
Sample 3: Format Strings
The FormatString
property specifies the format that will be used to display the number. Use standard or
custom .NET number format strings.
The exact format of the number is determined from the culture that was used in the HTTP request on the server. You can find more info in the Globalization tutorial.
<bp:NumericUpDown Value="{value: Value}"
FormatString="C"
Step="{value: 0.1}"
MinValue="0" />
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.NumericUpDown.sample3
{
public class ViewModel : DotvvmViewModelBase
{
public double Value { get; set; }
}
}
Sample 4: Customizing Icons
The icons used by the control can be customized using the following properties:
DecreaseIconCssClass
represents an icon that allows to decrease the value. The default value isfa fa-minus
(FontAwesome).IncreaseIconCssClass
represents an icon that allows to increase the value. The default value isfa fa-plus
(FontAwesome).
<bp:NumericUpDown Value="{value: Value}"
DecreaseIconCssClass="decrease"
IncreaseIconCssClass="increase"
MinValue="0.5"
MaxValue="5"
Step="0.5" />
using DotVVM.BusinessPack.Controls;
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.NumericUpDown.sample4
{
public class ViewModel : DotvvmViewModelBase
{
public double Value { get; set; } = 1.5;
}
}
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
AutoFocus | Boolean | Gets or sets whether the control should have focus when page loads or when a dialog is opened. The default value is false. |
attribute
static value
|
False | |
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
static value
bindable
|
null | |
DecreaseIconCssClass | String | Gets or sets the CSS class for the icon displayed on the decrease button. The default value is FaMinus. |
attribute
static value
|
fa fa-minus | |
Enabled | Boolean | Gets or sets whether the control is enabled and can be modified. |
attribute
static value
bindable
|
True | |
FormatString | String | Gets or sets format string used to display the Value. |
attribute
static value
|
G | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
|
null | |
IncreaseIconCssClass | String | Gets or sets the CSS class for the icon displayed on the increase button. The default value is FaPlus. |
attribute
static value
|
fa fa-plus | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
MaxValue | Double? | Gets or sets the maximum the Value must be less than or equal to. |
attribute
static value
bindable
|
null | |
MinValue | Double? | Gets or sets the minimum the Value must be greater than or equal to. |
attribute
static value
bindable
|
null | |
Placeholder | String | Gets or sets the text displayed when the Value is empty. |
attribute
static value
|
null | |
Step | Double | Gets or sets a value used to increment or decrement the Value. |
attribute
static value
bindable
|
1 | |
TabIndex | Int32 | Gets or sets the order in which the control is reachable in sequential keyboard navigation. The default value is 0 which means the document order. |
attribute
static value
|
0 | |
UseFormatStringAsPlaceholder | Boolean | Gets or sets whether to use FormatString as a placeholder when Placeholder property is not set. It is enabled by default. |
attribute
static value
|
True | |
Value | Double? | Gets or sets the value displayed in the control. |
attribute
bindable
|
null | |
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True |
Events
Name | Type | Description | |
---|---|---|---|
Changed | Command | Gets or sets the command that will be triggered when the value is changed. |