how to keep same position in form after postback?

Discussion in 'ASP .Net' started by Dan, May 22, 2008.

  1. Dan

    Dan Guest

    Hi,

    I made a form consisting of a lot of server-controls (dropdownlist,
    radiobuttonlist ...). Some controls have their property 'autoPostBack' =
    true because some things must happen when selectedvalue is changed.

    My problem: suppose that the property 'autoPostBack' of 20th control is
    true, each time the user changes the selectedvalue, he is sent back to the
    top of the form after postback. He has then to scroll down to find the 21th
    control.

    Is there any way to impede that and to keep the same poition in the form
    after postback?

    Thanks
    Dan
    Dan, May 22, 2008
    #1
    1. Advertising

  2. Dan

    Teemu Keiski Guest

    Hi,

    you can set MaintainScrollPositionOnPostBack="True" to Page directive
    (starting in ASP.NET 2.0)

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net

    "Dan" <> wrote in message
    news:...
    > Hi,
    >
    > I made a form consisting of a lot of server-controls (dropdownlist,
    > radiobuttonlist ...). Some controls have their property 'autoPostBack' =
    > true because some things must happen when selectedvalue is changed.
    >
    > My problem: suppose that the property 'autoPostBack' of 20th control is
    > true, each time the user changes the selectedvalue, he is sent back to the
    > top of the form after postback. He has then to scroll down to find the
    > 21th control.
    >
    > Is there any way to impede that and to keep the same poition in the form
    > after postback?
    >
    > Thanks
    > Dan
    >
    Teemu Keiski, May 22, 2008
    #2
    1. Advertising

  3. There is a property on the Page object in .NET 2.0
    MaintainScrollPositionOnPostBack
    Set it to true.

    Basically when form is submitted JavaScript remembers current scroll
    position in hidden variable (input type=hidden).
    Then when page comes back from POST scroll position is restored with
    JavaScript.


    George.


    "Dan" <> wrote in message
    news:...
    > Hi,
    >
    > I made a form consisting of a lot of server-controls (dropdownlist,
    > radiobuttonlist ...). Some controls have their property 'autoPostBack' =
    > true because some things must happen when selectedvalue is changed.
    >
    > My problem: suppose that the property 'autoPostBack' of 20th control is
    > true, each time the user changes the selectedvalue, he is sent back to the
    > top of the form after postback. He has then to scroll down to find the
    > 21th control.
    >
    > Is there any way to impede that and to keep the same poition in the form
    > after postback?
    >
    > Thanks
    > Dan
    >
    George Ter-Saakov, May 22, 2008
    #3
  4. Dan

    Dan Guest

    Thanks

    "George Ter-Saakov" <> schreef in bericht
    news:...
    > There is a property on the Page object in .NET 2.0
    > MaintainScrollPositionOnPostBack
    > Set it to true.
    >
    > Basically when form is submitted JavaScript remembers current scroll
    > position in hidden variable (input type=hidden).
    > Then when page comes back from POST scroll position is restored with
    > JavaScript.
    >
    >
    > George.
    >
    >
    > "Dan" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> I made a form consisting of a lot of server-controls (dropdownlist,
    >> radiobuttonlist ...). Some controls have their property 'autoPostBack' =
    >> true because some things must happen when selectedvalue is changed.
    >>
    >> My problem: suppose that the property 'autoPostBack' of 20th control is
    >> true, each time the user changes the selectedvalue, he is sent back to
    >> the top of the form after postback. He has then to scroll down to find
    >> the 21th control.
    >>
    >> Is there any way to impede that and to keep the same poition in the form
    >> after postback?
    >>
    >> Thanks
    >> Dan
    >>

    >
    >
    Dan, May 22, 2008
    #4
    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. Steve C. Orr, MCSD
    Replies:
    0
    Views:
    814
    Steve C. Orr, MCSD
    Aug 1, 2003
  2. elain
    Replies:
    1
    Views:
    951
    John Saunders
    Nov 21, 2003
  3. Ken McCrory

    Keep previous page position after postback

    Ken McCrory, Mar 9, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,082
    Ken McCrory
    Mar 9, 2005
  4. parm
    Replies:
    2
    Views:
    16,544
  5. peruukki
    Replies:
    1
    Views:
    551
    peruukki
    May 31, 2007
Loading...

Share This Page