Checked State
This help article showcases how to check/uncheck the RadCheckBox control on the server-side/client-side.
Get/Set Checked State Server-Side
You can get/set the checked state of the RadCheckBox control on the server-side through the Checked
property.
The
Checked
property takes a nullable boolean. When a null value is set, theChecked
value will default to false. This is useful for data-binding scenarios when theChecked
property is bound to a data source field of nullable boolean type.
Example 1: Check RadCheckBox in the markup.
<telerik:RadCheckBox ID="RadCheckBox1" runat="server" Text="I agree" Checked="true"></telerik:RadCheckBox>
Example 2: Get/Set the Checked property from the server-side.
protected void Page_Init(object sender, EventArgs e)
{
bool isChecked = RadCheckBox1.Checked;
RadCheckBox1.Checked = !isChecked;
}
Get/Set Checked State Client-Side
To get/set the checked state of the RadCheckBox control on the client-side you can use the get_checked()
and set_checked()
properties of the control.
Example 3: Toggle the initial checked state of RadCheckBox.
function pageLoad() {
var checkBox = $find("<%=RadCheckBox1.ClientID%>");
var isChecked = checkBox.get_checked();
checkBox.set_checked(!isChecked);
}
<telerik:RadCheckBox ID="RadCheckBox1" runat="server" Text="I agree" Checked="true"></telerik:RadCheckBox>