如何获得隐藏的字段值? [英] How to get hidden field value?

查看:97
本文介绍了如何获得隐藏的字段值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在除ASPX页面后面的代码之外的类文件中获取ASPX页面的隐藏字段值。例如A.aspx有一些隐藏字段,我想在A.cs中使用它而不是A.aspx背后的代码。我可以这样做吗?

解决方案

如果你想直接访问代码文件以外的代码文件,那么 - - 你做不了。相反,您可以访问后面代码中的隐藏字段并将其传递给类文件。



替代解决方案:

您可以存储值在会话中使用HiddenField,然后你可以在整个应用程序的任何代码文件中访问隐藏字段的值。





--Amit


当您希望跨页面使用此值时,隐藏字段不是很有用。

使用会话或cookie(状态管理)来跨页面访问此值。

I want to get Hidden Field value of a ASPX page in a class file other than code behind of the ASPX page.For Example A.aspx is having some hidden field and I want to use it in A.cs which is not the code behind of A.aspx.How can I do this???

解决方案

If you want to access it directly on code files other than code behind file then -- "You cannot do it". Instead you can access the hidden field in code behind and pass it to the class file.

Alternative solution:
You can store the value of HiddenField in session and then you can access the value of the hidden field in any code file throughout the application.


--Amit


Hidden field is not so useful when you want this value across the pages.
use session or cookie (state mamagement ) for accessing this values across the pages.


这篇关于如何获得隐藏的字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆