更新面板回发触发器 [英] update panel post back trigger

查看:130
本文介绍了更新面板回发触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我可以使用带有异步回发触发器的更新面板,但是具有他的代码的页面无法正常工作..我在此页面中具有滚动条..n每当我向下滚动时,它都会自动向上滚动...我该如何解决这个问题问题

hi!
i ma using update panel with asynchronous post back trigger but the page which is having his code doesnot work properly..i have scroll bar in this page..n when ever i scroll down it automatically scrolls up...how could i resolve this problem

<pre lang="xml"><asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"><br />
                                                   <ContentTemplate><br />
                                                       <div id="ChatContent" runat="server" style="height: 355px; vertical-align: top; overflow-y: auto;<br />
                                                           text-align: left; margin-left: 10px; width: 97%;"><br />
                                                       </div><br />
                                                   </ContentTemplate><br />
                                                   <Triggers><br />
                                                       <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /><br />
                                                   </Triggers><br />
                                               </asp:UpdatePanel><br />
                                               <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"><br />
                                               </asp:Timer></pre><br />

推荐答案

我认为这应该对您有用

在页面上的ScriptManager之后,将以下脚本放在之后.而且由于PageRequestManager的_endRequest事件发生在呈现页面之前,所以您不会看到页面移动

I think this should work for you

Put the following script after the ScriptManager on your page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you wont see your page move

<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').scrollLeft; yPos =


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


这篇关于更新面板回发触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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