New to Telerik UI for ASP.NET Core? Download free 30-day trial

NumericTextBox in Razor Pages

Razor Pages is an alternative to the MVC pattern that makes page-focused coding easier and more productive. This approach consists of a cshtml file and a cshtml.cs file (by design, the two files have the same name).

You can seamlessly integrate the Telerik UI NumericTextBox for ASP.NET Core in Razor Pages applications.

This article describes how to configure the NumericTextBox component in a Razor Pages scenario.

For the complete project, refer to the NumericTextBox in Razor Pages example.

Getting Started

To bind the Telerik UI NumericTextBox within a RazorPage:

  1. Declare the PageModel at the top of the RazorPage:

        @model Telerik.Examples.RazorPages.Pages.NumericTextBoxBindingModel
  2. Declare the widget either in a form or as a stand-alone widget:

        <form method="post">
            <label for="Price">Price:</label>
            <br />
            <input type="submit" name="name" value="Submit Form" />
  3. Bind the property values in the backend:

        public class NumericTextBoxBindingModel : PageModel
            public int Price { get; set; }
            public void OnGet()
                //omitted for clarity
            public void OnPost()
                //omitted for clarity

See Also

In this article