异步回发后保持滚动位置 [英] Maintain Scroll Position after Asynchronous Postback

查看:42
本文介绍了异步回发后保持滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,如果updatepanel回发,该项目将滚动回到顶部,因为它已被重新加载。您需要做的是记住项目滚动到的位置,并在回发后跳回到那里。在页面上的ScriptManager之后编写以下脚本。并且由于PageRequestManager的_endRequest事件发生在页面呈现之前,你甚至都不会看到你的项目移动但是具有计时器的更新面板不工作计时器dosnt开始或更新



任何人都可以为它提供解决方案



< script type =text / javascript>

var xPos,yPos;

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(BeginRequestHandler);

prm .add_endRequest(EndRequestHandler);

函数BeginRequestHandler(sender,args){

xPos = $ get('scrollDiv')。scrollLeft;

yPos = $ get('scrollDiv')。scrollTop;

}

函数EndRequestHandler(sender,args){

$ get('scrollDiv ')。scrollLeft = xPos;

$ get('scrollDiv')。scrollTop = yPos;

}

< / script> < br $>




Plz得到一些必要的解决方案。

Normally, if the updatepanel posts back, the item will scroll back to the top because it has been reloaded. What you need to do is "remember" where the item was scrolled to and jump back to there after the postback.writting the following script after the ScriptManager on page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item move but the update panel having the timer is not working the timer dosnt get started or updated

can anyone provide the solution for it

<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('scrollDiv').scrollLeft;
yPos = $get('scrollDiv').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('scrollDiv').scrollLeft = xPos;
$get('scrollDiv').scrollTop = yPos;
}
</script>


Plz get some needfull solution fot the same.

推荐答案

get('scrollDiv')。scrollLeft;

yPos =
get('scrollDiv').scrollLeft;
yPos =


get('scrollDiv')。scrollTop;

}

函数EndRequestHandler(sender,args) {
get('scrollDiv').scrollTop;
}
function EndRequestHandler(sender, args) {


get('scrollDiv')。scrollLeft = xPos;
get('scrollDiv').scrollLeft = xPos;


这篇关于异步回发后保持滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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