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

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
 
G

Guest

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
 
M

matt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top