简体   繁体   English

HiddenField在asp.net中回发时丢失

[英]HiddenField Lost on postback in asp.net

We have an asp.net web page with a Hidden control on it: 我们有一个带隐藏控件的asp.net网页:

<asp:HiddenField runat="server" id="inputValue" />

Which holds information entered by a user for use later. 其中包含用户输入的信息,供以后使用。 The page also has this in the head section of the web page to refresh the page every 20 seconds: 该页面的顶部还包含此内容,以便每20秒刷新一次页面:

<meta http-equiv="refresh" content="20"> 

This is done to refresh the page with new information from a database. 这样做是为了使用数据库中的新信息刷新页面。

Now if I use in my code behind the inputValue.Value i can correctly get the value entered by a person. 现在,如果我在inputValue.Value后面的代码中使用,我就可以正确获取人输入的值。 However if the page refreshes before I need to get this value then inputValue.Value will be empty. 但是,如果在需要获取该值之前刷新页面,则inputValue.Value将为空。

So my question is how can I make sure that inputValue.Value will have the informaton saved to it after the page refreshes? 所以我的问题是,如何确保在刷新页面后将inputValue.Value保存到其中? Javascript is out of the question as some of the devices accessing this page can not run javascript. 由于访问该页面的某些设备无法运行javascript,因此无法使用javascript。

Thanks 谢谢

刷新将仅重新加载URL,因此您必须将状态存储在querystring中

Thanks, in doing some research that is what I was coming to find out. 谢谢,在做一些研究之后,我才发现了这一点。 Since I'm not passing data from one page to the next, would a session variable work? 由于我没有将数据从一页传递到下一页,因此会话变量可以工作吗?

And tested with the session variable and works great. 并使用会话变量进行了测试,效果很好。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM