我可以避免 UpdatePanel 杀死视图状态吗?

发布于 2024-07-25 07:08:01 字数 525 浏览 2 评论 0原文

我的选择页面有一个网格视图,向用户呈现一个数据项列表,他们可以单击这些数据项来“钻取” - 将他们重定向到数据维护页面。

由于列表可能会很长,因此我们在顶部有一系列复选框和下拉列表作为过滤器。

我们刚刚实现了带有 UpdatePanelAnimationExtender 的 UpdatePanel,这样当页面长途返回数据库时,他们会弹出一个漂亮的“正在处理...”。

问题是,这似乎破坏了下拉列表和复选框的视图状态。 现在,当他们转到“详细信息页面”并点击“返回”按钮返回“选择”页面时,复选框和下拉列表中的选定值将恢复为其初始默认值。 列表仍然填充,但当用户单击数据维护页面时,它们“忘记”了它们所拥有的内容。

我取出了 UpdatePanel 的 .aspx 代码,并对动画进行了扩展和重新测试,一切都运行良好。 因此,显然,UpdatePanel 和/或 AnimationExtender 与视图状态的配合不太好。

有没有办法阻止 UpdatePanel 的操作,实际上将“.SelectedValue”属性归零?

I selection page that has a gridview that presents the user with a list of data items that they can click on to "drill into" - redirecting them to the data maintenance page.

Because the list can get long, we have a series of check boxes and drop-down lists at the top that act as filters.

We just implemented an UpdatePanel with an UpdatePanelAnimationExtender so that when the page made long trips back to the databse, they would get a nice "Processing..." pop up.

Problem is, this seems to break the viewstate on the drop-down lists and check boxes. Now, when they go to the 'detail page' and hit the BACK button to get back to the 'selection' page - the selected values in the checkboxes and drop-downlists are back to their initial defaults. The lists are still populated, but they 'forgot' what they had when the user clicked to the data maintenance page.

I took out the .aspx code for the UpdatePanel and the animation extended and retested and everything worked perfectly. So, apparently, the UpdatePanel and/or the AnimationExtender doesn't play nice with the viewstate.

Is there a way I can stop the UpdatePanel's actions from, in effect, zeroing out the '.SelectedValue" properties?

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

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

发布评论

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

评论(1

身边 2024-08-01 07:08:01

首先,我将从 UpdatePanel 中删除“过滤”控件。 假设这些控件的数据在 Page_Load 上赋值,则每次将筛选器应用于 GridView 时,不需要刷新它们。 仅刷新 GridView,因此它可能是 UpdatePanel 中应包含的唯一控件。

通过在 UpdatePanel 控件的 部分中声明每个过滤控件,都可以将其添加为更新 UpdatePanel 的触发器。 或者,如果过滤过程是由“提交”之类的按钮调用的,那么这将是要在该部分中声明的控件。 这应该将过滤控件的值保留在浏览器的缓存中。

您还可以尝试 Nikhil Kothari 的 UpdateHistory 控件(顺便说一句,Nikhil 有一个很棒的博客)这将节省UpdatePanel 的内容作为浏览器历史列表中的历史条目。

编辑:仅供参考,UpdatePanel 不会“杀死”ViewState。 ViewState 通过 UpdatePanel 的更新机制来回传输,如果 ViewState 过大,通常会导致性能问题。 您看到的是浏览器的历史记录缓存不存储在连续回调中更新的值。 上述技术应该有所帮助。

First I would remove your "filtering" controls from the UpdatePanel. Assuming that the data for these controls are valued on Page_Load, they do not need to be refreshed every time the filter is applied to the GridView. Only the GridView is being refreshed, so it's likely that it is the only control that should be contained in the UpdatePanel.

Each of the filtering controls can be added as a trigger for updating the UpdatePanel by declaring them in the section of the UpdatePanel control. Or, if the filtering process is invoked by a "submit" like button, that would be the control to be declared in the section. This should retain the values of the filtering controls in the browser's cache.

You can also try Nikhil Kothari's UpdateHistory control (Nikhil has an excellent blog, btw) which will save the contents of the UpdatePanel as history entries in the browser's history list.

EDIT: FYI, UpdatePanel does not "kill" ViewState. The ViewState is transmitted back and forth via the UpdatePanel's update mechanism, often causing performance issues if the ViewState is excessively large. What you're seeing is the browser's history cache not storing the values that have been updated on successive callbacks. The above techniques should help.

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