Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Server-side controls repositing long client forms to top

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Networxpro - 07 Sep 2007 14:54 GMT
Whenever an ASP.NET server-side control is processed, the client form is
repainted from the top forcing users to scroll back to where they were on
long forms.  How can I work around this issue?

For example run this, scroll down and click the left check box:

<%@ Page Language=vb %>
<html>
<script runat=server>
Sub Test(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Box2.Checked = Box1.Checked
End Sub
</script>

<body>
 <form id="Form1" method="post" runat="server">
   <TABLE>
     <TR><TD height=1500 bgcolor=red></TD></TR>
     <TR>
       <TD>
         <asp:CheckBox id=Box1 runat="server" AutoPostBack=True
           OnCheckedChanged=Test></asp:CheckBox>
       </TD><TD>
         <asp:CheckBox id=Box2 runat="server"></asp:CheckBox>
       </TD>
     </TR>
   </TABLE>
 </form>
</body>
</html>
Peter Bromberg [C# MVP] - 07 Sep 2007 15:38 GMT
Just set the MaintainScrollPositionOnPostback directive to True, either on
the page-level or in Web.config if you want it to apply to all pages in the
website. For a single page, update the <% @Page  directive so that it looks
lkike:

<%@ Page Language="..." MaintainScrollPositionOnPostback="true" ... %>  

To apply the setting to all pages in the website, add the following to the
Web.config file (within the <system.web> element):

<pages maintainScrollPositionOnPostBack="true" />  

-- Peter
Recursion: see Recursion
site:  http://www.eggheadcafe.com
unBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder:    http://www.blogmetafinder.com

> Whenever an ASP.NET server-side control is processed, the client form is
> repainted from the top forcing users to scroll back to where they were on
[quoted text clipped - 26 lines]
> </body>
> </html>
Networxpro - 07 Sep 2007 17:40 GMT
Thanks, but unfortunately this site is running .NET Framework 1.1 and
MaintainScrollPositionOnPostback is new in 2.0

Any other suggestions?

> Just set the MaintainScrollPositionOnPostback directive to True, either on
> the page-level or in Web.config if you want it to apply to all pages in the
[quoted text clipped - 44 lines]
> > </body>
> > </html>
bruce barker - 07 Sep 2007 18:51 GMT
just do the same logic. in clientscript, in onsubmit, store the x & y in
a hidden fields. then on postback render if x & y are filled in, render
 client script to set the scroll position.

-- bruce (sqlwork.com)

> Thanks, but unfortunately this site is running .NET Framework 1.1 and
> MaintainScrollPositionOnPostback is new in 2.0
[quoted text clipped - 49 lines]
>>> </body>
>>> </html>
Networxpro - 09 Sep 2007 00:22 GMT
Thanks Bruce & Peter.

Your tips and a search led me to a couple of simple solutions that I can
easily apply to our various webforms:

Steve Stchur's "Maintaining Scroll Position on Postback"
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx

Ibrahim Uludag's "Crossbrowser SmartNavigation Alternatives"
http://www.codeproject.com/aspnet/lili2.asp

Thanks for the help!
Networxpro

> just do the same logic. in clientscript, in onsubmit, store the x & y in
> a hidden fields. then on postback render if x & y are filled in, render
[quoted text clipped - 55 lines]
> >>> </body>
> >>> </html>

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.