Edit this page

Events Overview

RadToggleButton exposes several client-side events that allow easy and flexible use in a wide range of application scenarios:

To handle the desired event, the user must set the respective property to the name of the JavaScript function handling the event or to an anonymous JavaScript function. Here is an example:

Example 1: Passing a named (non-anonymous) JavaScript function.

<script type="text/javascript">
    function Click(sender, args)
    {
        alert("RadToggleButton was clicked.");
    }
</script>
<telerik:RadToggleButton ID="RadToggleButton1" runat="server" OnClientClicked="Click">
    <ToggleStates>
        <telerik:ButtonToggleState Text="State 1" />
        <telerik:ButtonToggleState Text="State 2" />
    </ToggleStates>
</telerik:RadToggleButton>
RadToggleButton1.OnClientClicked = "Click";  //passing the name of the JS function
RadToggleButton1.OnClientClicked = "Click"  'passing the name of the JS function

Example 2: Passing an anonymous JavaScript function.

<script type="text/javascript">
    function Click(button, args, arg1, arg2)
    {
        alert("arg1:" + arg1 + " arg2:" + arg2);
    }
</script>

<telerik:RadToggleButton ID="RadToggleButton1" runat="server" OnClientClicked="function(sender,args){Click(sender, args, 'Value1', 'Value2');}">
    <ToggleStates>
        <telerik:ButtonToggleState Text="State 1" />
        <telerik:ButtonToggleState Text="State 2" />
    </ToggleStates>
</telerik:RadToggleButton>
RadToggleButton1.OnClientClicked = "function(sender,args){Click(sender, args, 'Value1', 'Value2');}"; //passing an anonymous JS function
RadToggleButton1.OnClientClicked = "function(sender,args){Click(sender, args, 'Value1', 'Value2');}"  'passing an anonymous JS function

See Also