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.
我见过一些人会说你必须使用JS .style.display ='none';并且.NET .Visible = false将不起作用。
What is the difference between the two and why would something work with the JS and not with the .NET?
这两者有什么区别,为什么有些东西可以用JS而不用.NET呢?
An example is http://www.componentart.com/forums/ShowPost.aspx?PostID=27586 (see the bottom post)
一个例子是http://www.componentart.com/forums/ShowPost.aspx?PostID=27586(见底部帖子)
Thanks
3 个解决方案
#1
-
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
display:none完全隐藏元素0px * 0px,但HTML元素仍然存在于源代码中
Visible = false从HTML输出中删除HTML元素
第三个选项,visibility:hidden隐藏元素,但在布局中为其保留空间
#2
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.
这实际上取决于组件,在asp.net的默认容量中将控件Visible属性设置为false将阻止将其呈现为输出流。但是对于一些自定义组件,它可能只是设置一个样式属性来隐藏渲染的元素。我相信在案例中指出有问题的ComponentArt控件依赖于内置控件,如果将内置控件可见性设置为false,则可能会破坏ComponentArt控件的功能。
#3
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.
设置Visible =“false”意味着控件根本不会呈现给客户端,style.display ='none'将呈现控件,只是不显示它。
#1
-
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
display:none完全隐藏元素0px * 0px,但HTML元素仍然存在于源代码中
Visible = false从HTML输出中删除HTML元素
第三个选项,visibility:hidden隐藏元素,但在布局中为其保留空间
#2
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.
这实际上取决于组件,在asp.net的默认容量中将控件Visible属性设置为false将阻止将其呈现为输出流。但是对于一些自定义组件,它可能只是设置一个样式属性来隐藏渲染的元素。我相信在案例中指出有问题的ComponentArt控件依赖于内置控件,如果将内置控件可见性设置为false,则可能会破坏ComponentArt控件的功能。
#3
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.
设置Visible =“false”意味着控件根本不会呈现给客户端,style.display ='none'将呈现控件,只是不显示它。