How to Check the Check Status of Checkbox in ASP.Net

Here, In ASP.Net Checkbox control Example, we teach you how to know the Check Status of Checkbox control Programmatically in ASP.Net with C#.

STEP 1 – Design the CheckBox ASP.Net web page like :

<table border=”1″ bordercolor=”#000000″ style=”z-index: 100; left: 272px; position: absolute;
top: 72px”>
<tr>
<td colspan=”3″ style=”width: 582px”>
<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>
<tr>
<td colspan=”2″ style=”height: 24px; text-align: center”>
<strong>Check which checbox is Checked</strong></td>
</tr>
<tr>
<td style=”width: 181px; height: 24px; text-align: right;”>
</td>
<td style=”width: 255px; height: 24px;”>
&nbsp;<asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”YES” Font-Bold=”True” />
&nbsp;&nbsp;
<asp:CheckBox ID=”CheckBox2″ runat=”server” Font-Bold=”True” Text=”NO” /></td>
</tr>
<tr>
<td style=”width: 181px”>
</td>
<td style=”width: 255px”>
<asp:Button ID=”btnchecked” runat=”server” OnClick=”btnchecked_Click” Text=”Check” />&nbsp;</td>
</tr>
<tr>
<td style=”width: 181px”>
</td>
<td style=”width: 255px”>
<asp:Label ID=”lblanswer” runat=”server”></asp:Label></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

The ASP.Net Checkbox Example output is :

CheckBox control in ASP.Net with C#
CheckBox control in ASP.Net with C#

STEP 2 – write below code on Button Click Event in ASP.Net aspx.cs page:

    protected void btnchecked_Click(object sender, EventArgs e)
{
if (CheckBox1.Checked == true && CheckBox2.Checked==false)
{
lblanswer.Text = “YES is Selected”;
}
else if(CheckBox2.Checked==true && CheckBox1.Checked==false)
{
lblanswer.Text = “NO is Selected”;
}
else if (CheckBox1.Checked == true && CheckBox2.Checked == true)
{
lblanswer.Text = “BOTH are Selected”;
}
else
{
lblanswer.Text = “BOTH are Un-Selected”;
}
}

The ASP.Net Checkbox Example output is :

CheckBox control in ASP.Net with C#
CheckBox control in ASP.Net with C#

The ASP.Net Checkbox Example output is :

 CheckBox control in ASP.Net with C#

CheckBox control in ASP.Net with C#

The ASP.Net Checkbox Example output is :

CheckBox control in ASP.Net with C#
CheckBox control in ASP.Net with C#

I hope this Checkbox control ASP.Net Example will help you……..

Leave a Reply

Your email address will not be published. Required fields are marked *