Lazy Loading of updatePanel content on startup => Page scrolls to top

123qwe

New Member
my website contains grid controls filled with data from a huge xml file. Dynamically creating these takes time - so I have been trying for the last two days to better understand the concept of and implement: update panels.I almost got it working.. What bugs me is that when the page loads, it scrolls back to the top after the UpdatePanel has been updated. On the other hand, when I click the button that triggers the async postback manually, everything is fine .. I see the UpdateProgress-icon I defined and after a short time, the grids appear and if I have scrolled down before the UpdatePanel has finished loading, there is no automatic scrolling to the top - just as I want. WHY is the page scrolling back to the top when it is requested for the first time?I tried different ways to fix when the event should be fired
  • pageLoad()
  • $(document).ready())
  • Sys.Application.add_init(function ()
I tried several ways of invoking the async trigger button
  • __doPostBack('<%= hiddenAsyncTrigger.ClientID %>', 'OnClick');
  • document.getElementById("hiddenAsyncTrigger").click();)
  • in codeBehind via ClientScript.RegisterStartupScript
I tried setting "Me.MaintainScrollPositionOnPostBack = True" in Page_Init,.. anything I tried resulted in the page scrolling to the top if the page is requested.What I have not tried so far is something like a timer.. or saving the scroll.top-value before the update (ugly...).Please, if someone could explain to me why I observe this behaviour, I would be very grateful. I'm sure it must be some basic mistake .. I just don't see it. (PS: VS2012, .NET 4.5)Definition of UpdateProgress & UpdatePanel:\[code\]<asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate><img src="http://stackoverflow.com/questions/14491636/img/progress.gif" /></ProgressTemplate></asp:UpdateProgress><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="TvMagazinPanel" runat="server"></asp:Panel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="hiddenAsyncTrigger" EventName="Click" /> </Triggers></asp:UpdatePanel>\[/code\]Some lines downwards: my Button, linked to a sub in the codeBehind.\[code\]<asp:Button ID="hiddenAsyncTrigger" runat="server" Text="AsyncUpdate" OnClick="createProgramm" />\[/code\]Some more lines downwards: the part where I am trying to attach the invokation of the button to a moment when the document has finished loading:\[code\]<script type="text/javascript"> Sys.Application.add_init(function () { __doPostBack('<%= hiddenAsyncTrigger.ClientID %>', 'OnClick'); //document.getElementById("hiddenAsyncTrigger").click(); });</script>\[/code\]
 
Back
Top