I find that when you are a new programmer or a programmer using a technology for the first time, there are a few gotchas’ that could make or break your learning experience. When learning the power of .NET, especially after developing primarily in PHP, the differences between Visible=”false” and display:none; was a huge gotcha for me. I figured I’d help you realize what exactly the differences are and when you should use one or the other. Take the source code:
<asp:Panel style="display:none;"> Error Message </asp:Panel>
<asp:Panel Visible="false"> Error Message </asp:Panel>
If you were to render both of these, you would see the screen the same thing: nothing. However, if you look at the source of both of them, you will realize that the former will appear in the source but the latter will not. That’s because in the first example, command display:none is CSS, which is client-side and in the second example, “Visible” is a server-side. On more complex pages, they are very much different.
When to use the display:none;
When to use Visible=”false”
I hope this helps you better understand the differences between the two types of hiding elements in .NET. If you have any questions, let me know!