ASP.NET Core ColorPalette Overview
The ColorPalette is part of Telerik UI for ASP.NET Core, a
professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
The Telerik UI ColorPalette TagHelper and HtmlHelper for ASP.NET Core are server-side wrappers for the Kendo UI ColorPalette widget.
Initializing the ColorPalette
The following example demonstrates how to define the ColorPalette.
@(Html.Kendo().ColorPalette()
.Name("colorpalette") // The name of the ColorPalette is mandatory. It specifies the "id" attribute of the widget.
.Value("#ff0000") // Set the value of the ColorPalette.
)
<kendo-colorpalette name = "colorpalette"
value="#ff0000">
</kendo-colorpalette>
Events
You can subscribe to all ColorPalette events.
Handling by Handler Name
The following example demonstrates how to subscribe to events by a handler name.
@(Html.Kendo().ColorPalette()
.Name("colorpalette")
.Events(e => e
.Change("colorpalette_change")
)
)
<kendo-colorpalette name = "colorpalette"
on-change="colorpalette_change">
</kendo-colorpalette>
<script>
function colorpalette_change(e) {
// Handle the change event.
var colorpalette = this;
console.log(colorpalette.value());
}
</script>
Handling by Template Delegate
The following example demonstrates how to subscribe to events by a template delegate.
@(Html.Kendo().ColorPalette()
.Name("colorpalette")
.Events(e => e
.Change(@<text>
function(e) {
// Handle the change event inline.
console.log(e.sender.value());
}
</text>)
)
)
Referencing Existing Instances
To reference an existing Telerik UI ColorPalette instance, use the jQuery.data()
configuration option. Once a reference is established, use the ColorPalette client-side API to control its behavior.
// Place the following after your Telerik UI ColorPalette for ASP.NET Core declaration.
<script>
$(function() {
// The Name() of the ColorPalette is used to get its client-side instance.
var colorpalette = $("#colorpalette").data("kendoColorPalette");
});
</script>