Server-side controls repositing long client forms to top

Discussion in 'ASP .Net' started by =?Utf-8?B?TmV0d29yeHBybw==?=, Sep 7, 2007.

  1. 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>
     
    =?Utf-8?B?TmV0d29yeHBybw==?=, Sep 7, 2007
    #1
    1. Advertising

  2. 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



    "Networxpro" wrote:

    > 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>
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Sep 7, 2007
    #2
    1. Advertising

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

    Any other suggestions?

    "Peter Bromberg [C# MVP]" wrote:

    > 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
    >
    >
    >
    > "Networxpro" wrote:
    >
    > > 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>
     
    =?Utf-8?B?TmV0d29yeHBybw==?=, Sep 7, 2007
    #3
  4. =?Utf-8?B?TmV0d29yeHBybw==?=

    bruce barker Guest

    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)

    Networxpro wrote:
    > Thanks, but unfortunately this site is running .NET Framework 1.1 and
    > MaintainScrollPositionOnPostback is new in 2.0
    >
    > Any other suggestions?
    >
    > "Peter Bromberg [C# MVP]" wrote:
    >
    >> 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
    >>
    >>
    >>
    >> "Networxpro" wrote:
    >>
    >>> 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>
     
    bruce barker, Sep 7, 2007
    #4
  5. 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

    "bruce barker" wrote:

    > 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)
    >
    > Networxpro wrote:
    > > Thanks, but unfortunately this site is running .NET Framework 1.1 and
    > > MaintainScrollPositionOnPostback is new in 2.0
    > >
    > > Any other suggestions?
    > >
    > > "Peter Bromberg [C# MVP]" wrote:
    > >
    > >> 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
    > >>
    > >>
    > >>
    > >> "Networxpro" wrote:
    > >>
    > >>> 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>

    >
     
    =?Utf-8?B?TmV0d29yeHBybw==?=, Sep 9, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    14
    Views:
    4,213
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  2. Mong
    Replies:
    5
    Views:
    4,767
    Kevin Spencer
    May 7, 2004
  3. msnews
    Replies:
    0
    Views:
    462
    msnews
    May 27, 2005
  4. Zoe Hart
    Replies:
    1
    Views:
    401
    Scott Wisniewski
    Jan 8, 2004
  5. Networxpro
    Replies:
    2
    Views:
    115
    Bob Barrows [MVP]
    Sep 7, 2007
Loading...

Share This Page