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

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>

Next Steps

See Also

In this article