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

Events

The ToggleButton exposes a Toggle() event that you can handle.

For a complete example on basic ToggleButton events, refer to the demo on using the events of the ToggleButton.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    @(Html.Kendo().ToggleButton()
        .Name("toggleButton")
        .Content("Sample ToggleButton")
        .Events(events => events.Toggle("onToggle"))
    )

    <script>
        function onToggle(e){
            // Handle the ToggleButton Toggle event that is triggered when selected state is toggled.
        };
    </script>
    <kendo-togglebutton name="toggleButton"
              on-toggle="onToggle">
        Sample ToggleButton
    </kendo-togglebutton>

     <script>
        function onToggle(e){
            // Handle the ToggleButton Toggle event that is triggered when selected state is toggled.
        };
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

    @(Html.Kendo().ToggleButton()
        .Name("toggleButton")
        .Content("Sample ToggleButton")
        .Events(events => events.Toggle(@<text>
            function() {
                // Handle the ToggleButton Toggle event inline.
            }
        </text>))
    )
    <kendo-togglebutton name="toggleButton"
              on-toggle="function(){
                // Handle the ToggleButton Toggle event inline.
              }">
        Sample ToggleButton
    </kendo-togglebutton>

Next Steps

See Also

In this article