NumericTextBox
The NumericTextBox HtmlHelper extension is a server-side wrapper for the Kendo UI NumericTextBox widget.
Here is how to configure a simple Kendo NumericTextBox:
Make sure you have followed all the steps from the Introduction help topic.
Create a new action method which renders the view:
public ActionResult Index()
{
return View();
}
Add a numerictextbox:
WebForms
<%: Html.Kendo().NumericTextBox()
.Name("numerictextbox") //The name of the numerictextbox is mandatory. It specifies the "id" attribute of the widget.
.Min(-100) //Set min value of the numerictextbox
.Max(100) //Set min value of the numerictextbox
.Value(10) //Set the value of the numerictextbox
%>
Razor
@(Html.Kendo().NumericTextBox()
.Name("numerictextbox") //The name of the numerictextbox is mandatory. It specifies the "id" attribute of the widget.
.Min(-100) //Set min value of the numerictextbox
.Max(100) //Set min value of the numerictextbox
.Value(10) //Set the value of the numerictextbox
)
You can reference an existing NumericTextBox instance via jQuery.data().
Once a reference has been established, you can use the API to control its behavior.
//Put this after your Kendo NumericTextBox for ASP.NET MVC declaration
<script>
$(function() {
// Notice that the Name() of the numerictextbox is used to get its client-side instance
var numerictextbox = $("#numerictextbox").data("kendoNumericTextBox");
});
</script>
You can subscribe to all events exposed by Kendo UI NumericTextBox:
<%: Html.Kendo().NumericTextBox()
.Name("numerictextbox")
.Events(e => e
.Change("numerictextbox_change")
.Spin("numerictextbox_spin")
)
%>
<script>
function numerictextbox_spin() {
//Handle the spin event
}
function numerictextbox_change() {
//Handle the change event
}
</script>
@(Html.Kendo().NumericTextBox()
.Name("numerictextbox")
.Events(e => e
.Change("numerictextbox_change")
.Spin("numerictextbox_spin")
)
)
<script>
function numerictextbox_spin() {
//Handle the spin event
}
function numerictextbox_change() {
//Handle the change event
}
</script>
@(Html.Kendo().NumericTextBox()
.Name("numerictextbox")
.Events(e => e
.Change(@<text>
function() {
//Handle the change event inline
}
</text>)
.Spin(@<text>
function() {
//Handle the spin event inline
}
</text>)
)
)