Server-side controls repositing long client forms to top

G

Guest

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>
 
G

Guest

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
 
G

Guest

Thanks, but unfortunately this site is running .NET Framework 1.1 and
MaintainScrollPositionOnPostback is new in 2.0

Any other suggestions?
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top