Example of Default Functionalities in ASP.NET MVC NumericTextBox Control
This sample demonstrates the default functionalities of the Numeric TextBox. Type a value in the input element to change the value dynamically, or press up/down arrow button to increase/decrease the value with a predefined step value.
Numeric TextBox
Percentage TextBox
Currency TextBox
@Html.UiNumericTextBox("numeric", new UiNumericTextBoxOptions { Value = 10 })
@Html.UiNumericTextBox("percentage", new UiNumericTextBoxOptions { Format = "P2", Value = 0.5, Min = 0, Max = 1, Step = 0.01 })
@Html.UiNumericTextBox("currency", new UiNumericTextBoxOptions { Format = "C2", Value = 100 })
<style>
.content-wrapper { width: 90%; max-width: 420px; margin: 0 auto; min-width: 185px; }
.content-wrapper .control-label { padding: 24px 0 10px; font-size: 12px; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.property-section .prop-input { width: 100px; padding: 4px 6px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
</style>
<div class="control-section">
<div class="content-wrapper">
<div class="control-label">Numeric TextBox</div>
@Html.UiNumericTextBox("numeric", new UiNumericTextBoxOptions { Value = 10 })
<div class="control-label">Percentage TextBox</div>
@Html.UiNumericTextBox("percentage", new UiNumericTextBoxOptions { Format = "P2", Value = 0.5, Min = 0, Max = 1, Step = 0.01 })
<div class="control-label">Currency TextBox</div>
@Html.UiNumericTextBox("currency", new UiNumericTextBoxOptions { Format = "C2", Value = 100 })
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class NumericTextBoxController : Controller
{
// The page is Views/NumericTextBox/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The NumericTextBox component is used to get the number inputs from the user. The input values can be increased or decreased with a predefined step value.
In this demo, the default NumericTextBox is rendered with the percent and currency formats as specified in MSDN