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

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

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

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

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


    @(Html.Kendo().ColorPicker()
        .Name("picker") 
        .ClearButton(Model.ClearButton)
        .Buttons(Model.Buttons)
        .Value(Model.Value)
    )


    public bool ClearButton { get; set; }   
    public bool Buttons { get; set; }
    public string Value { get; set; }

    public void OnGet()
    {
        ClearButton = true;
        Buttons = false;
        Value = "#94ed67";
    }

See Also

In this article