If I set some control\'s property Visible=\"false\", I cant see the control in the HTML generated of my aspx page. But when I use display:none in style tag for that control,
If you want to dynamically show or hide the control via Ajax/etc, or if the control contains information your page needs, set display:none
in CSS.
If you don't want to render the control at all in certain situations, set Visible="false"
. Since it keeps the control's HTML out of the page, it makes for slightly smaller pages -- but if you want to show the control via Ajax/etc, this won't work.
If you don't want to render the control at all, period, don't comment it out -- remove it altogether. All controls, visible or not, still require processing, so Visible=false is wasting CPU (and possibly causing side effects) if you never intend to render the control. And you really don't want lots of commented-out stuff floating around; it just makes maintenance harder. You can always get it back from your revision control if you find you do need it later. (You are using SVN/Git/CVS/something, right?)