Events
The Switch for ASP.NET Core exposes the Change()
event that you can use for capturing the Switch's value during user interaction.
For a complete example on Switch events, refer to the demo on using the events of the Slider.
Handling by Handler Name
The following example demonstrates how to subscribe to events by a handler name.
@(Html.Kendo().Switch()
.Name("switch")
.Events(e => e
.Change("change")
)
)
<script>
function change(e) {
// Handle the change event.
}
</script>
<kendo-switch name="switch" on-change="change"></kendo-switch>
<script>
function change(e) {
// Handle the change event.
}
</script>
Handling by Template Delegate
The following example demonstrates how to subscribe to events by a template delegate.
@(Html.Kendo().Switch()
.Name("switch")
.Events(e => e
.Change(@<text>
function(e) {
// Handle the change event inline.
}
</text>)
)
)
<kendo-switch name="switch"
on-change="function() {
// Handle the change event inline.
}">
</kendo-switch>