ASP.NET:定时器和滚动位置 [英] ASP.NET: Timer and scroll position

查看:104
本文介绍了ASP.NET:定时器和滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

得到一个UpdatePanel内的计时器。它不断地刷新(大约每2.5秒)。如果刷新滚动时它设置滚动位置回到它是berfore了部分更新:(

Got a timer inside an updatepanel. It constantly refreshes (about every 2.5 seconds). If it refreshed while scrolling it sets the scroll position back to what it was berfore the partial update :(

我使用ASP.NET 3.5和MaintainScrollPositionOnPostback设置为false(即使设置为true的行为不会改变)。

I'm using ASP.NET 3.5 and MaintainScrollPositionOnPostback is set to false (even if set to true behaviour doesn't change).

不知道为什么会这样,但可用性是烦人......

No clue why this happens, but usability is annoying...

亲切的问候, 萨沙

推荐答案

我们也有类似的问题,在异步回发会重置用户到一个很长的页面的顶部。 http://forums.asp.net/:我们发现以下code在后解决它T / 1047815.aspx

We had a similar problem where an asynchronous postback would reset the user to the top of a very long page. We resolved it after finding the following code at: http://forums.asp.net/t/1047815.aspx

我们插入下面的JavaScript在我们的页面上的使用ScriptManager在页面上。

We inserted the following javascript on our page after the ScriptManager on the page.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(beginRequest);

    function beginRequest() {
        prm._scrollPosition = null;
    }
</script>

这使得所以回传并没有重置用户滚动位置时回传回来。

This made it so the postback did not reset the users scroll position when the postback returned.

我不知道如果这正是你所遇到的问题。您还可以看看这篇文章:<一个href="http://stackoverflow.com/questions/616210/reset-scroll-position-after-async-postback-asp-net">http://stackoverflow.com/questions/616210/reset-scroll-position-after-async-postback-asp-net其中讨论了一个回发发生后设置滚动位置的更可靠的方法。

I'm not sure if this is exactly the problem that you are experiencing. You could also take a look at this post: http://stackoverflow.com/questions/616210/reset-scroll-position-after-async-postback-asp-net which discusses a more robust method of setting the scroll position after a postback occurs.

这篇关于ASP.NET:定时器和滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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