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

RadioGroup 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 RadioGroup for ASP.NET Core in Razor Pages applications.

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

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

    @page
    @model Telerik.Examples.RazorPages.Pages.RadioGroup.RadioGroupIndexModel

    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <h1>RadioGroup</h1>

    @(Html.Kendo().RadioGroup()
            .Name("radiogroup")
            .Items(i =>
            {
                i.Add().Label("Phone (SMS)").Value("1");
                i.Add().Label("E-mail").Value("2");
                i.Add().Label("None").Value("3");
            })
            .Value("1")
    )
    @page
    @model Telerik.Examples.RazorPages.Pages.RadioGroup.RadioGroupIndexModel

    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <h1>RadioGroup</h1>

    <kendo-radiogroup name="radiogroup" 
                      radio-name="radiogroup" 
                      value="1">
          <kendo-radiogroup-items>
              <kendo-radiogroup-item label="Phone (SMS)" value="1"></kendo-radiogroup-item>
              <kendo-radiogroup-item label="E-mail" value="2"></kendo-radiogroup-item>
              <kendo-radiogroup-item label="None" value="3"></kendo-radiogroup-item>
          </kendo-radiogroup-items>
    </kendo-radiogroup>
    public class RadioGroupIndexModel : PageModel
    {
        public void OnGet()
        {
        }
    }

See Also

In this article