Telerik UI NumericTextBox in Razor Pages
Razor Pages are an alternative to the MVC pattern. Razor Pages make page-focused coding easier and more productive. This approach consists of a cshtml
file and a cs
file (generally, the two files have the same name). You can seamlessly integrate the Telerik UI NumericTextBox for ASP.NET Core in Razor Pages applications.
For a runnable example, refer to the NumericTextBox in RazorPages example.
Getting Started
To bind the Telerik UI NumericTextBox within a RazorPage
:
-
Declare the
PageModel
at the top of theRazorPage
:@page @model Telerik.Examples.RazorPages.Pages.NumericTextBoxBindingModel
-
Declare the widget either in a form or as a stand-alone widget:
<form method="post"> <label for="Price">Price:</label> @(Html.Kendo().NumericTextBoxFor(c=>c.Price) .Step(1) .Min(0) .Decimals(0) ) <br /> <input type="submit" name="name" value="Submit Form" /> </form>
-
Bind the property values in the backend:
public class NumericTextBoxBindingModel : PageModel { [BindProperty] public int Price { get; set; } public void OnGet() { //omitted for clarity } public void OnPost() { //omitted for clarity } }