I have a checkbox that I am hiding on certain conditions. I have a label associated with each checkbox that is being populated based on a Boolean value. The problem I am facing is that I want to keep each label, but hide only the check boxes. I know I can make a label and just show it after I hide the checkbox. I am just curious as if there is a way to remove the checkbox but keep the text shown.
chkbox.Visible = false;
lblName.Text = Bool_Code == BooleanType.No ? "No" : "Yes";
If you set
chkbox.Visible = false then the control is NOT rendered at all.
Now because the check box in asp.net is rendered with two html tags, you can do this.
Disable the checkbox for avoid to click on it in any casem, but still rendered and Hide the input control with style. To do the second part you use the
InputAttributes that referred only on
chkbox.Enabled = false; chkbox.InputAttributes["style"] = "display:none;";