In order to hide a control, a lot of developers set the Visible property of the control to True. However what this does is that it does not Render the control, so you cannot set a value to the control.
If you want to Render the Control and also keep it invisible at the same time ‘programmatically’, use the CssStyleCollection. So for example, if you have three textboxes tbOne, tbTwo, tbThree and want to render the textbox tbTwo but keep it invisible, use the following code
tbTwo.Style.Add(HtmlTextWriterStyle.Display, "none");
What this essentially does is that it sets the display style of the textbox to none.
Note: You could have declared a Css class and then set the TextBox CssClass to it, but I wanted to demo an example that can be done programmatically at server side.
Tweet
1 comment:
Hi, thank you, please correct the following: "In order to hide a control, a lot of developers set the Visible property of the control to -> False" instead of True.
Post a Comment