维护滚动位置和回发时的选定控制

发布于 2024-12-27 14:47:59 字数 389 浏览 4 评论 0原文

返回另一个基于网络的问题。

当控件向服务器发出回发时,页面会刷新(很好)。页面也会滚动回顶部并失去所选的控件。如果回发后相关,则根据发生的更改,控件将变得可见或隐藏。即使页面可见性没有任何变化,焦点也会丢失并且当前滚动会重置。在文本字段中输入的数据以及任何单选按钮/复选框选择都会被保留。问题是 Tab 键重置为索引 0 并且页面滚动被发送回页面顶部。

我正在使用.Net 4.0,

我尝试在asp页面本身和web.config中添加MaintainScrollPositionOnPostback =“true”,但无济于事。 我尝试过使用或不使用 Ajax updatepanel,使用条件更新在文本框文本更改或单选按钮更改时触发,并且回发仍然会导致滚动和索引丢失。

任何 ide 都会很棒。塔!

Back with another web based issue.

When a control issues a postback to the server the page refreshes (Fine). The page also scrolls back to the top and loses the control that is selected. If it's relevent after the postback depending on what changes have happened controls are made visible or made hidden. The focus is lost and current scroll resets even if nothing is changed on the page visibility wise. The data inputted in Text fields is kept and so are any radiobutton/checkbox selections. The problem is tabbing is reset to index 0 and the pages scroll is sent back to the top of the page.

I am using .Net 4.0

I have tried adding MaintainScrollPositionOnPostback="true" both on the asp page itself and in the web.config to no avail.
I have tried with and without the Ajax updatepanel using conditional updating triggering off when textboxes text is changed or radiobuttons are changed and the postback still causes a scroll and index loss.

Any ides would be fantastic. Ta!

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

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

发布评论

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

评论(1

小草泠泠 2025-01-03 14:47:59

首先,MaintainScrollPositionOnPostback="true" 在 asp.net 2.0 中存在一个已知错误,请参阅 此处

另外,正确的语法是 maintainScrollPositionOnPostback。 (小写m)

我使用了 maintainScrollPositionOnPostback 但在 IE 中遇到了很多问题,然后我使用了 asp.net AJAX Control Toolkit UpdatePanel,它解决了问题(页面不滚动到顶部)并且节省一些带宽。

编辑:

我想我理解你的问题,它保持对元素的关注,可以使用一些 javascript 解决方法来完成,se 这里

希望有帮助。

First of all, the MaintainScrollPositionOnPostback="true" has a known bug in asp.net 2.0, see here.

Also, the correct syntax is maintainScrollPositionOnPostback. (lowercase m)

I used the maintainScrollPositionOnPostback but have many problems in IE, then I use the asp.net AJAX Control Toolkit UpdatePanel, it solves the problem (the page don't scroll to the top) and save some bandwidth.

EDIT:

I think I understand your problem, it's mantain the focus on the element, it can be done using some javascripts workarounds, se here.

Hope that helps.

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