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

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

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

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

    @page
    @model Telerik.Examples.RazorPages.Pages.RadioButon.RadioButtonIndexModel
    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <h4>Agree to Terms and Conditions:</h4>
    <ul class="fieldlist">
        <li>
            @(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I Agree").Value(true))
        </li>
        <li>
            @(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I Disagree").Value(false))
        </li>
    </ul>
    @page
    @model Telerik.Examples.RazorPages.Pages.RadioButon.RadioButtonIndexModel
    @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
    @Html.AntiForgeryToken()

    <h4>Agree to Terms and Conditions:</h4>
    <ul class="fieldlist">
        <li>
            <kendo-radiobutton name="IAgreeProp" label="I Agree" value="true"></kendo-radiobutton>
        </li>
        <li>
            <kendo-radiobutton name="IAgreeProp" label="I Disagree" value="false"></kendo-radiobutton>
        </li>
    </ul>
    [BindProperty]
    public bool IAgreeProp { get; set; }
    public void OnGet()
    {
        IAgreeProp = true;
    }
In this article