DOT

VVM

 DOCS

Version: 1.0 | 1.1 |

NumericUpDown

in namespace DotVVM.BusinessPack.Controls

Renders an <input> element with buttons on the side that increase or decrease the value.

Properties

Name Type Description Notes Default Value
Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
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
ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
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
inner element
static value
bindable
default
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
Enabled Boolean Gets or sets whether the control is enabled and can be modified.
attribute
inner element
static value
bindable
default
True
FormatString String Gets or sets format string used to display the Value.
attribute
inner element
static value
bindable
default
G
ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
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
InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
MaxValue Double? Gets or sets the maximum the Value must be less than or equal to.
attribute
inner element
static value
bindable
default
MinValue Double? Gets or sets the minimum the Value must be greater than or equal to.
attribute
inner element
static value
bindable
default
Placeholder String Gets or sets the text displayed when the Value is empty.
attribute
inner element
static value
bindable
default
Step Double Gets or sets a value used to increment or decrement the Value.
attribute
inner element
static value
bindable
default
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
inner element
static value
bindable
default
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
inner element
static value
bindable
default
True
Value Double? Gets or sets the value displayed in the control.
attribute
inner element
static value
bindable
default
Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

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

Usage & Scenarios

A text field which allows to enter numeric values and to increase or decrease them by the specified step.

HTML Rendered by the Control

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;
    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message