Hide and visible CheckBox programmatically
CheckBox is an asp.net web server control that allow the users to select a true or false condition.
checkbox control have a built in property to show or hide itself programmatically at run time.
checkbox Visible property get or set a value which indicate whether the checkbox control is rendered as UI on web page. checkbox Visible property value type is System.Boolean, so we can only assign true or false for this property value.
Visible property value 'true' means the checkbox control will render in web browser as UI. if we set the checkbox Visible property value to 'false' then it will hide the checkbox control from web page. simply Visible property value indicate that the checkbox will not render in web browser as UI (user interface). by using this property we can control the checkbox visibility programmatically.
the following asp.net c# example code demonstrate us how can we show or hide a checkbox control dynamically at run time in an asp.net application.
checkbox Visible property get or set a value which indicate whether the checkbox control is rendered as UI on web page. checkbox Visible property value type is System.Boolean, so we can only assign true or false for this property value.
Visible property value 'true' means the checkbox control will render in web browser as UI. if we set the checkbox Visible property value to 'false' then it will hide the checkbox control from web page. simply Visible property value indicate that the checkbox will not render in web browser as UI (user interface). by using this property we can control the checkbox visibility programmatically.
the following asp.net c# example code demonstrate us how can we show or hide a checkbox control dynamically at run time in an asp.net application.
CheckBoxVisible.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
CheckBox1.Visible = false;
Label1.Text = "CheckBox Hide.";
}
protected void Button2_Click(object sender, System.EventArgs e)
{
CheckBox1.Visible = true;
Label1.Text = "CheckBox Visible.";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to hide, visible CheckBox programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Green">asp.net CheckBox example: Hide, Visible</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Large"
ForeColor="Violet"
>
</asp:Label>
<br /><br />
<asp:CheckBox
ID="CheckBox1"
runat="server"
Text="Check The CheckBox."
AutoPostBack="false"
ForeColor="Tomato"
/>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="Violet"
Text="Hide CheckBox"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="Violet"
Text="Visible CheckBox"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>



- How to hide, visible ListBox programmatically
- How to use DropDownList AutoPostBack feature
- How to change DropDownList BackColor (background color) programmatically
- How to set, change DropDownList border color programmatically
- How to set, change DropDownList border style programmatically
- How to data bind DropDownList on page load
- How to set, change DropDownList data source programmatically