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

Getting Started with the Telerik WebForms CheckBox

The following tutorial demonstrates how to set up a page with a RadCheckBox control and use its OnCheckedChanged server event:

1) In the default page of a new ASP.NET AJAX-enabled Web Application add a RadCheckBox control:

<telerik:RadCheckBox ID="RadCheckBox1" runat="server" />

2) Set the Text, Value and CommandArgument properties:

<telerik:RadCheckBox ID="RadCheckBox1" runat="server" Text="Some Text" Value="0" CommandArgument="arg1" />

3) To hook to the OnCheckedChanged server-side event of RadCheckBox add an attribute to the main control tag and add the method signature:

<telerik:RadCheckBox ID="RadCheckBox1" runat="server" OnCheckedChanged="RadCheckBox1_CheckedChanged" Text="Some Text" Value="0" CommandArgument="arg1" />
protected void RadCheckBox1_CheckedChanged(object sender, EventArgs e)
{

}
Protected Sub RadCheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub

5) Add a Label control to write the information to:

<asp:Label ID="Label1" Text="" runat="server" />

6) Use the CheckedChanged event handler to write information about the checkbox properties:

protected void RadCheckBox1_CheckedChanged(object sender, EventArgs e)
{
    RadCheckBox checkbox = sender as RadCheckBox;

    string data = string.Format("current text: {0}, current value {1}, current command argument: {2}, checked: {3}",
                                checkbox.Text, checkbox.Value, checkbox.CommandArgument, checkbox.Checked);
    Label1.Text = data;
}
Protected Sub RadCheckBox1_CheckedChanged(sender As Object, e As EventArgs)
    Dim checkbox = TryCast(sender, RadCheckBox)

    Dim data As String = String.Format("current text: {0}, current value {1}, current command argument: {2}, checked: {3}", checkbox.Text, checkbox.Value, checkbox.mmandArgument, checkbox.Checked)
    Label1.Text = data
End Sub

See Also

In this article