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 is fa fa-minus (FontAwesome).

  • IncreaseIconCssClass represents an icon that allows to increase the value. The default value is fa 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
property icon Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
null
property icon 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
inner element
static value
bindable
default
False
property icon ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
Static
property icon 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
inner element
static value
bindable
default
null
property icon DecreaseIconCssClass String Gets or sets the CSS class for the icon displayed on the decrease button. The default value is FaMinus.
attribute
inner element
static value
bindable
default
fa fa-minus
property icon Enabled Boolean Gets or sets whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
property icon FormatString String Gets or sets format string used to display the Value.
attribute
inner element
static value
bindable
default
G
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon IncreaseIconCssClass String Gets or sets the CSS class for the icon displayed on the increase button. The default value is FaPlus.
attribute
inner element
static value
bindable
default
fa fa-plus
property icon InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
null
property icon MaxValue Double? Gets or sets the maximum the Value must be less than or equal to.
attribute
inner element
static value
bindable
default
null
property icon MinValue Double? Gets or sets the minimum the Value must be greater than or equal to.
attribute
inner element
static value
bindable
default
null
property icon Placeholder String Gets or sets the text displayed when the Value is empty.
attribute
inner element
static value
bindable
default
null
property icon Step Double Gets or sets a value used to increment or decrement the Value.
attribute
inner element
static value
bindable
default
1
property icon 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
inner element
static value
bindable
default
0
property icon UseFormatStringAsPlaceholder Boolean Gets or sets whether to use FormatString as a placeholder when Placeholder property is not set. It is enabled by default.
attribute
inner element
static value
bindable
default
True
property icon Value Double? Gets or sets the value displayed in the control.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
event icon Changed Command Gets or sets the command that will be triggered when the value is changed.

HTML produced by the control