[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Re: Restore scroll position of a DIV over a postback

JezB

7/5/2004 3:26:00 PM

Well, it did work partly : if the control which causes the postback is in
the scrollable DIV it does rescroll far enough to focus on it if I turn
smart navigation on, but not EXACTLY to the same scroll position (so user
sees it jump from middle to bottom, for example). Also, if the control which
caused the postback was outside the scrollable area it always scrolled
itself back to the top. Therefore I had to come up with a better solution.

"JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
news:u$FPqKpYEHA.2408@tk2msftngp13.phx.gbl...
> Well, I did try that first, obviously.
> But it didn't work.
>
> "MA" <news@supremelink.se> wrote in message
> news:2kt2j1F61tt9U1@uni-berlin.de...
> > Or you could use:
> >
> > Page.SmartNavigation = true;
> >
> > /Marre
> >
> > "JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
> > news:eCjAEFnYEHA.2500@TK2MSFTNGP09.phx.gbl...
> > > Never mind. I found a way. For the record:
> > >
> > > <body onload="javascript:scrollTo('scrollArea')" >
> > > <form id="Form1" method="post" runat="server">
> > > ...
> > > <div id="scrollArea onscroll="javascript:setScroll(this);"
> > > runat="server" style="vertical-align: top; height:200px; width:100%;
> > > overflow:auto;">
> > > <asp:DataGrid runat="server" ...>
> > > ...
> > > </asp:DataGrid>
> > > </div>
> > > <input type="hidden" id="scrollPos" name="scrollPos" value="0"
> > > runat="server">
> > > ...
> > > </form>
> > > <script language="javascript">
> > > function setScroll(val) {
> > > document.Form1.scrollPos.value = val.scrollTop;
> > > }
> > > function scrollTo(what) {
> > > document.getElementById(what).scrollTop =
> > > document.Form1.scrollPos.value;
> > > }
> > > </script>
> > > </body>
> > >
> > >
> > >
> > >
> > > "JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
> > > news:Oa2GXfmYEHA.3128@TK2MSFTNGP09.phx.gbl...
> > > > There are a few references on the net about how to restore a page's
> > scroll
> > > > position over a postback. This is a simple one which works for me:
> > > > eg.
> http://www.devhood.com/messages/message_view-2.aspx?thread...
> > > >
> > > > My question is : can the same thing be done to restore the scroll
> > position
> > > > of a specific DIV within a page? I have a DIV section which scrolls
> > > > independently to the page :
> > > > <div style="vertical-align: top; height:200px; width:100%;
> > > overflow:auto;">
> > > > <asp:DataGrid runat="server" ...>
> > > > ...
> > > > </asp:DataGrid>
> > > > </div>
> > > > On each postback it is scrolling back to the top. Very annoying to
the
> > > user
> > > > if it's a click within the scroll area that causes the postback.
> > > >
> > > > Could someone tell me how? My knowledge of javascript is almost
zero.
> > > >
> > > >
> > >
> > >
> >
> >
>
>