views:

336

answers:

3

I have seen some instances where people will say you have to use JS .style.display = 'none'; and that .NET .Visible = false will not work.

What is the difference between the two and why would something work with the JS and not with the .NET?

An example is http://www.componentart.com/forums/ShowPost.aspx?PostID=27586 (see the bottom post)

Thanks

+1  A: 
  • display: none completely hides the element, 0px * 0px, but the HTML element is still there in the source
  • Visible = false removes the HTML element from the HTML output
  • A third option, visibility: hidden hides the element but reserves the space for it in the layout
DrJokepu
A: 

That really depends on the component, at a default capacity in asp.net setting a controls Visible property to false will prevent rendering it to the output stream at all. However with some custom components it may just set a style attribute to hide the rendered elements. I believe in the case pointed out the ComponentArt control in question is dependent on a built in control and if you set the built in control visibility to false it might break the functionality of the ComponentArt control.

Quintin Robinson
A: 

Setting Visible="false" means that the control will not be rendered to the client at all, style.display='none' will render the control, just not show it.

Brandon