问题描述
如何在服务器端使用 C# 访问隐藏字段的内容,其中 hiddenfiled 的可见性设置为 Visible=false
.我不适合使用 CSS 的 display:none
而不是 Visible=false
.
How can I access the content of hidden field, where the hiddenfiled's visibility set to Visible=false
in the server side using C#. I am not in a situation to use CSS's display:none
instead of Visible=false
.
推荐答案
如果 Visible
是 false
,那么控件没有下到客户端,所以你不能直接从 javascript 访问它:它根本不存在.
If Visible
is false
, then the control did not go down to the client, so you cannot directly access it from javascript: it simply isn't there.
同样,既然是一个HiddenField
(即),就不需要设置
display:none
- 它不会永远可见,即使 Visible
是 true
(尽管它会在源代码中).
Equally, since it is a HiddenField
(i.e.<input type="hidden"...>
), there is no need to set display:none
- it will never be visible, even if Visible
is true
(although, it will be in the source).
所以:要么将 Visible
设置为 true
,要么返回服务器获取该值.
So: either set Visible
to true
, or come back to the server to get that value.
这篇关于如果 Visibility 设置为 false,则访问隐藏字段值(使用 C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!