ASP.NET 2.0:如何使页面记住视图状态而不创建历史点?

发布于 2024-07-09 09:49:48 字数 256 浏览 7 评论 0原文

我有一个页面,上面有一些字段和运行时生成的图像。 此页面的内容位于 UpdatePanel 内。 有一个按钮可以将用户带到辅助页面,该按钮有一个在单击时调用 javascript:history.go(-1) 的按钮。

问题是,第一页执行完整请求,而不是回发或仅使用离开它之前的状态。 也就是说,这些字段都被重置为其默认值,从而使用户感到困惑。 我希望无论导航如何,都保留它们的值。 我不想为每个字段更改创建新的历史状态。

有任何想法吗?

I have a page with a few fields and a runtime-generated image on it. The contents of this page are inside an UpdatePanel. There is a button to take the user to a secondary page, which has a button that calls javascript:history.go(-1) when clicked.

The problem is, the first page does a full request instead of a postback or just using the state it was in before navigating away from it. That is, the fields are all reset to their default values, thereby confusing the user. I'd like their values to be retained regardless of navigation. I do not want to create a new history state for every field change.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情话墙 2024-07-16 09:49:48

唯一的其他选择是使用 JavaScript(有限制)跟踪客户端 cookie 中的字段状态。 最好在导航到辅助页面之前执行 AJAX 调用,这将允许服务器保存页面的状态,以便当发生反向导航时,您可以将该状态正确地呈现给浏览器。

The only other option would be to track the field state in a client side cookie using JavaScript (which has limitations). It would be best to have an AJAX call that was executed prior to navigation to your secondary page that would allow the server to save the state of the page so that when your reverse navigation occurred you could properly render that state to the browser.

夜巴黎 2024-07-16 09:49:48

我想当我有更多的时间来研究它时,我会尝试 AJAX 的想法。 我可能只会发回视图状态字段:P 感谢您的输入。

I think I'll try the AJAX idea when I have a little more time to work on it. I'll probably just send back the viewstate field :P Thanks for the input.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文