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

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

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

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

@page
@model Telerik.Examples.RazorPages.Pages.ButtonGroup.ButtonGroupIndexModel
@{
    ViewData["Title"] = "ButtonGroupIndex";
}

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

<h1>ButtonGroupIndex</h1>

@(Html.Kendo().ButtonGroup()
    .Name("buttonGroup")
    .Items(t =>
    {
        t.Add().Text("Month");
        t.Add().Text("Quarter");
        t.Add().Text("Year");
    })
    .Events(ev => ev.Select("onSelect"))
)
        <kendo-buttongroup name="player"
                            on-select="onSelect">
                <buttongroup-items>
                    <item text="Month"></item>
                    <item text="Quarter"></item>
                    <item text="Year"></item>
                </buttongroup-items>
        </kendo-buttongroup>
<script>
    function onSelect(e) {
        console.log("selected index:" + e.indices);
    }
</script>
    public class ButtonGroupIndexModel : PageModel
    {
        public void OnGet()
        {

        }
    }

See Also

In this article