Enable / Disable CheckBox Control Programmatically in ASP.Net

In this ASP.Net CheckBox Exmaple, How to Enable and Disable CheckBox control Programmatically in ASP.Net with C#.

STEP 1 – Design ASP.Net web form with One CheckBox control along with the Two Button 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”>Enable / Disable
CheckBox Programmatically</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px;”>
&nbsp;
</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
&nbsp;<asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”CheckBox Enable / Disable” Font-Bold=”True” /></td>
</tr>
<tr>
<td style=”width: 257px”><asp:Button ID=”btnEnable” runat=”server” OnClick=”btnEnable_Click” Text=”Enable” Font-Bold=”True” />&nbsp;
<asp:Button ID=”btnDisable” runat=”server” OnClick=”btnDisable_Click” Text=”Disable” Font-Bold=”True” Width=”64px” /></td>
</tr>
<tr>
<td style=”width: 257px; text-align: center”>
<asp:Label ID=”lblanswer” runat=”server” Font-Bold=”True” ForeColor=”Maroon”></asp:Label></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

The ASP.Net Checkbox Example output is :

Enable / Disable CheckBox control in ASP.Net with C#
Enable / Disable CheckBox control in ASP.Net with C#

STEP 2 – write below code at ASP.Net code page:

protected void btnEnable_Click(object sender, EventArgs e)
{
CheckBox1.Enabled = true;
lblanswer.Text = “CheckBox Enable”;
}
protected void btnDisable_Click(object sender, EventArgs e)
{
CheckBox1.Enabled = false;
lblanswer.Text = “CheckBox Disable”;
}

The ASP.Net Checkbox Example output is :

Enable / Disable CheckBox control in ASP.Net with C#
Enable / Disable CheckBox control in ASP.Net with C#

The ASP.Net Checkbox Example output is :

Enable / Disable CheckBox control in ASP.Net with C#
Enable / Disable CheckBox control in ASP.Net with C#

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

Leave a Reply

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