如何在页面卸载和加载之间保留html隐藏输入字段中的值? [英] How to retain the values in html hidden input fields between page unloads and loads ?

查看:50
本文介绍了如何在页面卸载和加载之间保留html隐藏输入字段中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专业人士,



我有一些html选择控件在asp母版页上查询日期。



加载某个内容页面后,主页面会刷新,因此选择控件中的日期会被初始化并丢失新选择的值。



为了解决这个问题,我引入了一个html隐藏输入字段和主页面的'onbeforeUnload',将日期控件中的选定值分配给输入字段,希望放入它从这回到控件,但是当主页面加载回来时,输入字段也被初始化并且是空的。



我也试过设置EnableViewState = true for这个页面。



除了AJAX之外,请建议一个正确的方法来实现这个目标。我们不能在这个项目中使用AJAX。



提前谢谢。

Dear Professionals,

I have some html select controls querying dates on an asp master page.

When some content page is loaded the master page gets refreshed and hence the dates in the select controls are initialized back and loses the newly selected values.

To overcome this, I introduced a html hidden input field and 'onbeforeUnload' of the master page assigned the selected values in the date controls to the input field hoping to put it back to the controls from this, but when the master page loads back the input field is also initialized and is empty.

I have also tried setting EnableViewState=true for this page.

Please suggest a right way to achieve this apart from AJAX. We cannot use AJAX for this project.

Thanks in advance.

推荐答案

你应该使用代码类似于(HiddenField)Page.Master.FindControl(hdnField);
You should be using code similar to (HiddenField)Page.Master.FindControl("hdnField");


这篇关于如何在页面卸载和加载之间保留html隐藏输入字段中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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