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

OnClientToggleStateChanged

The toggleStateChanged event is subsequent to the toggleStateChanging event, and occurs when the RadToggleButton state is changed.

The event handler receives two parameters:

  1. The instance of the clicked RadToggleButton control.

  2. An eventArgs parameter of type Telerik.Web.UI.RadButtonCheckedEventArgs, containing the following properties and methods:

    • get_currentToggleState() - returns the current RadButtonToggleState object applied to the button.

    • get_commandName() - returns the value assigned to the RadToggleButton's CommandName property.

    • get_commandArgument() - returns the value assigned to the RadToggleButton's CommandArgument property.

This event is useful when the user wants to execute custom client code when the button changes its toggle state.

Example 1: Using the OnClientToggleStateChanged event to get the text of the currently selected state.

<script type="text/javascript">
    function toggleStateChanged(sender, args) {
        alert(args.get_currentToggleState().get_text());
    }
</script>

<telerik:RadToggleButton ID="RadToggleButton1" runat="server"
    AutoPostBack="false" OnClientToggleStateChanged="toggleStateChanged">
    <ToggleStates>
        <telerik:ButtonToggleState Text="State 1" />
        <telerik:ButtonToggleState Text="State 2" />
    </ToggleStates>
</telerik:RadToggleButton>

See Also

In this article