Here, we are going to learn in this ASP.Net Checkbox Example, How to change the check status of checkbox by change the another checkbox check status programmatically in ASP.Net with C#.
STEP 1 – Design the ASP.Net web page with Two CheckBox control:
<table border=”1″ bordercolor=”#000000″ style=”z-index: 100; left: 272px; position: absolute;
top: 72px”>
<tr>
<td colspan=”3″ style=”width: 582px; height: 100px;”>
<asp:Image ID=”Image1″ runat=”server” ImageUrl=”https://meeraacademy.com/wp-content/themes/elemin/uploads/logo/meeralogo.gif” /></td>
</tr>
<tr>
<td colspan=”3″ rowspan=”2″ style=”width: 582px; height: 21px; text-align: center”>
<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>Change CheckBox
Status by another CheckBox</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px;”><asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”CheckBox1″ Font-Bold=”True” AutoPostBack=”True” OnCheckedChanged=”CheckBox1_CheckedChanged” />
</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBox ID=”CheckBox2″ runat=”server” Text=”CheckBox2″ Font-Bold=”True” /></td>
</tr>
<tr>
<td style=”width: 257px; text-align: center”>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>
The ASP.Net Checkbox Example output is :
STEP 2 – write below code at ASP.Net code page:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
CheckBox2.Checked = true;
}
else
{
CheckBox2.Checked = false;
}
The ASP.Net Checkbox Example output is :
I hope this Checkbox control ASP.Net Example will help you……..