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

Razor Page

This article describes how to configure the Telerik UI Button for ASP.NET Core in a RazorPage scenario.

The example below demonstrates how to pass antiforgery token when a Button is clicked. See the implementation details in the example below, and for the full project with RazorPages examples, visit our GitHub repository.


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

    <form method="post">
        <input type="text" name="description">
        <br/>
        @(Html.Kendo().Button()
            .Name("primaryTextButton")
            .ThemeColor(ThemeColor.Primary)
            .HtmlAttributes(new { type = "submit" })
            .Events(e => e.Click("onClick"))
            .Content("Submit")
        )
    </form>

<form method="post">
    <input type="text" name="description">
    <br />
    <kendo-button name="primaryTextButton"
                   on-click="onClick"
                   theme-color="ThemeColor.Primary"
                   type="submit">
        Submit
    </kendo-button>

</form>
    <script>
        function onClick() {
            return kendo.antiForgeryTokens();
        }
    </script>

    public class ButtonIndexModel : PageModel
    { 
        public void OnPost(string description)
        {
            .....
        }
    }

See Also

In this article