简体   繁体   English

如果其可见性设置为false,则访问隐藏字段值(使用C#)

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

How can I access the content of hidden field, where the hiddenfiled's visibility set to Visible=false in the server side using C#. 我如何访问隐藏字段的内容,其中在服务器端使用C#将hiddenfiled的可见性设置为Visible=false I am not in a situation to use CSS's display:none instead of Visible=false . 我没有使用CSS的display:none代替Visible=false

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. 在服务器端设置Visisble=false时,它实际上不会在页面中呈现控件,因此无法在客户端获得该值。

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? 如果您确实无法通过其他方法将值放入页面中,可以在需要时发出AJAX请求以获取值?

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. 如果Visiblefalse ,则该控件不会传递给客户端,因此您无法直接从javascript访问它:它根本不存在。

Equally, since it is a HiddenField (ie <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). 同样,由于它是一个HiddenField (即<input type="hidden"...> ),因此无需设置display:none即使Visibletrue ,它也永远不会可见(尽管它将位于来源)。

So: either set Visible to true , or come back to the server to get that value. 因此:将Visible设置为true ,或者返回服务器以获取该值。

您不能-这些字段不会呈现给客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 javascript 设置隐藏字段的值,然后从服务器端 C# 代码访问值 - Using javascript to set value of hidden field then access value from serverside c# code C#工具提示:需要将光标可见性设置为false - C# tooltip : need cursor visibility set to false 如何创建一个接收图像作为参数的方法,并在c#中将其可见性更改为false - How can I make a method that receives an image as a parameter and changes its visibility to false in c# C# 窗口可见性,折叠和隐藏 - C# Window Visibility, collapsed and hidden 如何在javascript中设置asp.net隐藏字段并访问c#代码后面的值 - how to set asp.net hidden field in javascript and access the value in c# code behind 如何在C#Windows窗体中将Singleton userControl可见性设置为true或false? - How to set Singleton userControl visibility to true or false in C# windows forms? C#使用String.IsNullOrEmpty的结果设置标签的可见性 - C# Set the visibility of a label using the result of String.IsNullOrEmpty 使用隐藏字段是个好主意? (ASP.NET,C#) - using hidden fields a good idea? (ASP.NET, C#) 如何在 C# 中将标签的制表位值设置为 false? - how to set false to tabstop value for a label in C#? 设置标签在webmethod C#中的可见性 - set visibility of label inside webmethod c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM