Access hidden fields value if its Visibility set to false(using C#)

天大地大妈咪最大 提交于 2019-12-12 01:47:49

问题


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.


回答1:


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.

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).

So: either set Visible to true, or come back to the server to get that value.




回答2:


When you set Visisble=false on the server side it won't actually render the control in the page so there is no way to get the value on the client side.

If you really can't put the value in the page some other way you could do an AJAX request to get the value when you need it?




回答3:


You can't - these fields are not being rendered to the client side.



来源:https://stackoverflow.com/questions/7553626/access-hidden-fields-value-if-its-visibility-set-to-falseusing-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!