简体   繁体   English

在回发时维护滚动位置和选定控件

[英]Maintaining Scroll Position and Selected Control on Postback

Back with another web based issue. 回到另一个基于Web的问题。

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. 问题是标签被重置为索引0并且页面滚动被发送回页面顶部。

I am using .Net 4.0 我使用的是.Net 4.0

I have tried adding MaintainScrollPositionOnPostback="true" both on the asp page itself and in the web.config to no avail. 我尝试在asp页面本身和web.config中添加MaintainScrollPositionOnPostback =“true”都无济于事。 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. 我已尝试使用和不使用Ajax updatepanel使用条件更新触发关闭文本框文本更改或radiobuttons更改并且回发仍导致滚动和索引丢失。

Any ides would be fantastic. 任何想法都会很棒。 Ta! TA!

First of all, the MaintainScrollPositionOnPostback="true" has a known bug in asp.net 2.0, see here . 首先, MaintainScrollPositionOnPostback="true"在asp.net 2.0中有一个已知错误,请参见此处

Also, the correct syntax is maintainScrollPositionOnPostback . 另外,正确的语法是maintainScrollPositionOnPostback (lowercase m) (小写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. 我使用了maintainScrollPositionOnPostback但在IE中有很多问题,然后我使用asp.net AJAX Control Toolkit UpdatePanel,它解决了问题(页面不滚动到顶部)并节省了一些带宽。

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 . 我想我理解你的问题,它是关注元素的,它可以使用一些javascripts工作区来完成, 在这里

Hope that helps. 希望有所帮助。

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

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