How to Visible / Hide Checkbox Programmatically in ASP.Net

In this ASP.Net tutorials we will learn to change the Checkbox mode from Visible to Hide programmatically in ASP.Net C# with an Example.

STEP 1 – Design the ASP.Net web form with One Checkbox control, one Label control and 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”>Hide / Visible
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 Visible / Hide” Font-Bold=”True” /></td>
</tr>
<tr>
<td style=”width: 257px”><asp:Button ID=”btnVisible” runat=”server” OnClick=”btnVisible_Click” Text=”Visible” Font-Bold=”True” />&nbsp;
<asp:Button ID=”btnHide” runat=”server” OnClick=”btnHide_Click” Text=”Hide” Font-Bold=”True” Width=”64px” /></td>
</tr>
<tr>
<td style=”width: 257px; text-align: center”>
<asp:Label ID=”lblanswer” runat=”server”></asp:Label></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

The ASP.Net Checkbox Control Example output is :

Visible and Hide Checkbox control in ASP.Net with C#
Visible and Hide Checkbox control in ASP.Net with C#

STEP 2 – write below code at code behind file on Button Click Event of ASP.Net web page:

protected void btnVisible_Click(object sender, EventArgs e)
{
CheckBox1.Visible = true;
lblanswer.Text = “CheckBox is Visible”;
}
protected void btnHide_Click(object sender, EventArgs e)
{
CheckBox1.Visible = false;
lblanswer.Text = “CheckBox is Hide”;
}

The ASP.Net Checkbox Control Example output is :

Visible and Hide Checkbox control in ASP.Net with C#
Visible and Hide Checkbox control in ASP.Net with C#

The ASP.Net Checkbox Control Example output is :

Visible and Hide Checkbox control in ASP.Net with C#
Visible and Hide Checkbox control in ASP.Net with C#

I hope this ASP.Net Checkbox control example of Visible / Hide will help you….

Leave a Reply

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