OnClientClicked
The clicked event is subsequent to the toggleStateChanged event, and occurs when the RadToggleButton control is clicked. The event is fired after the client-side validation is completed (just like the PushButon's OnClientClicked event), just before the page is submitted, and cannot be canceled.
The event handler receives two parameters:
-
The instance of the clicked RadToggleButton control.
-
An eventArgs parameter of type Telerik.Web.UI.ButtonEventArgs, containing the following properties and methods:
-
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 can be used in scenarios where one needs custom client-side code to be executed when the button is clicked.
Example 1: Handling the OnClientClicked event.
<script type="text/javascript">
function clientClick(sender, args) {
var selectedValue = sender.get_selectedToggleState().get_value();
$get("<%= Textbox1.ClientID %>").value = selectedValue;
}
</script>
<span>Selected Value:</span>
<asp:TextBox ID="Textbox1" runat="server" />
<telerik:RadToggleButton ID="RadToggleButton1" runat="server" AutoPostBack="false"
OnClientClicked="clientClick">
<ToggleStates>
<telerik:ButtonToggleState Text="State 1" Value="Value1"/>
<telerik:ButtonToggleState Text="State 2" Value="Value2"/>
</ToggleStates>
</telerik:RadToggleButton>