滚动到ASP.Net Ajax的异步回发不后的JQuery页面顶部 [英] Scroll to top of page after ASP.Net Ajax Async-Postback without JQuery

查看:123
本文介绍了滚动到ASP.Net Ajax的异步回发不后的JQuery页面顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要滚动到页面顶部的异步回发后以更新面板。我试过几个方法,虽然他们都滚动到页面的顶部,他们都得到由ASP.Net Ajax的,它返回的页面时回发发生在哪里,这是重写。我在Page指令已经设置MaintainScrollPositionOnPostBack =假。

I need to scroll to the top of the page after an Async Postback in an update panel. I've tried a couple of methods, and while they all scroll to the top of the page, they all get "overriden" by ASP.Net Ajax which returns the page to where it was when the postback occurs. I have already set MaintainScrollPositionOnPostBack="false" in the Page directive.

推荐答案

你试过window.scrollTo(0,0); ?

Have you tried window.scrollTo(0, 0); ?

如果你有,也许setTimeout的结合在

If you have, perhaps combine in with setTimeout

window.setTimeout("window.scrollTo(0, 0)", 3000);

虽然我预计这可能会产生周围一些丑陋的跳跃。

Although I expect this might produce some ugly jumping around.

另一种方法是挂接到EndRequest事件处理程序

An alternative would be to hook into the EndRequest event handler

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
    window.scrollTo(0, 0);
} 

这篇关于滚动到ASP.Net Ajax的异步回发不后的JQuery页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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