Is there a way to make an ASP.Net control invisible other than the "visible" property?

  • Thread starter Thread starter john
  • Start date Start date
J

john

I have some controls that I want to be invisible, but if the user does
something, they will become visible using javascript. So I can't set
its "visible" property to false, because then they won't even be
rendered in the page at all. I can set them to invisible using
javascript, but I don't want to do that because then their visibility
isn't saved in the viewstate. Is there any way to make them invisible
from the code-behind file in a way that will be saved in the viewstate
and so that the controls can be accessed through client-side script?

thanks in advance
 
You can attach the style attribute and set it to invisible. That way, it is rendered on the client and you can change the property to visible in javascript

Tu-Thac
www.ongtech.co

----- john wrote: ----

I have some controls that I want to be invisible, but if the user doe
something, they will become visible using javascript. So I can't se
its "visible" property to false, because then they won't even b
rendered in the page at all. I can set them to invisible usin
javascript, but I don't want to do that because then their visibilit
isn't saved in the viewstate. Is there any way to make them invisibl
from the code-behind file in a way that will be saved in the viewstat
and so that the controls can be accessed through client-side script

thanks in advanc
 
If your control is named myControl

myControl.Style.Add("visibility","hidden");
-- or --
myControl.Style.Add("display", "none");

depending on whether you want the control to hold it's space. (display none
does not hold space in the page, where as setting the visibility will).

Matt
http://www.3internet.co.uk
 
Back
Top