Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. retain scrollbar position

retain scrollbar position

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-nettutorial
18 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jkirkerx

    I think what the OP is trying to say, Is that he has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.

    D Offline
    D Offline
    dcof
    wrote on last edited by
    #8

    You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.

    T J 2 Replies Last reply
    0
    • D dcof

      You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.

      T Offline
      T Offline
      Trak4Net
      wrote on last edited by
      #9

      I would imagine adapting something like the accepted answer in the stackoverflow link below would work. Since this is a server control you would need to assign the attribute for the onscroll client side event. Here are a couple links you might want to check out http://forums.asp.net/t/1045266.aspx/1[^] http://stackoverflow.com/questions/1094589/maintain-scroll-position-of-a-div-within-a-page-on-postback[^]

      J 1 Reply Last reply
      0
      • D dcof

        You are correct. This is what I am trying to say: There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top. How do I reset the scroll position to where the user left it, during a partial or whole page postback.

        J Offline
        J Offline
        jkirkerx
        wrote on last edited by
        #10

        Aw, The page lifecycle OnInit, Intialize the html elements on the page onLoad, load values for the html elements once the page does onInit, the html elements are cast in stone, and will not change Once the page does onLoad, you can populate values in the html elements During a postback to the server, the html elements are rock solid, and the values will remain, but things like scroll position reset back to default. The page does not have the ability to remember little details like scroll position MaintainScrollPosition is for the scroll of the whole page, and not a panel. But, maybe, instead of page.MaintainScrollPosiiton, you could do panelName.MaintainScrollPosition Other that that, you would have to take a measurement of the position, record it, and restore it back to the value, in theory I don't have an answer, I would have to think about it and experiment. A quick search gets this document.getElementById('box').scrollTop Persisting the scroll position of a DIV on AJAX postbacks [^] Maintain Scroll Position in Panel, Div[^] http://michaelsync.net/2006/06/30/maintain-scroll-position-of-div-using-javascript-aspnet-20[^] http://forums.asp.net/t/1359867.aspx[^]

        1 Reply Last reply
        0
        • T Trak4Net

          I would imagine adapting something like the accepted answer in the stackoverflow link below would work. Since this is a server control you would need to assign the attribute for the onscroll client side event. Here are a couple links you might want to check out http://forums.asp.net/t/1045266.aspx/1[^] http://stackoverflow.com/questions/1094589/maintain-scroll-position-of-a-div-within-a-page-on-postback[^]

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #11

          Yah I think I just posted the same link Good job!

          T 1 Reply Last reply
          0
          • D dcof

            Thanks for your answer. However that did not work. There is no postback involved most of the time. Basically I placed a checkbox list control within a panel that has a scrollbar. When the user has finished selecting all the items in the checkbox list control, they move on to other items on the web form page to enter. They have not clicked the 'next' button yet. There is no postback. The user does not want the scrollbar to go to the top area of the scroll. They want to stay where they left off entering selections. Thus do you know of other ways I can maintain the scrollbar position? I am currently not using ajax controls on this webpage.

            S Offline
            S Offline
            Sandeep Mewara
            wrote on last edited by
            #12

            dcof wrote:

            There is no postback involved most of the time.

            dcof wrote:

            There is no postback.The user does not want the scrollbar to go to the top area of the scroll. T

            Well, not possible! Without a postback, page would not return scroll to top by itself! My answer still holds. Try out. Both the options. For second one, use form onsubmit() event to store the scroll position and then restore it on form load.

            Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]

            1 Reply Last reply
            0
            • J jkirkerx

              Yah I think I just posted the same link Good job!

              T Offline
              T Offline
              Trak4Net
              wrote on last edited by
              #13

              Thats too funny. Looks like you covered it a little better than I did though so good job to you!

              J 1 Reply Last reply
              0
              • T Trak4Net

                Thats too funny. Looks like you covered it a little better than I did though so good job to you!

                J Offline
                J Offline
                jkirkerx
                wrote on last edited by
                #14

                Thanks, I figured the question was wrong, and the OP had no clue what was happening there. Well, hopefully, he learned something there today. These asp.net questions are getting harder to answer because the way the questions are phrased make no sense to me. One day, someone will ask a really good question Over and out, time to sleep

                1 Reply Last reply
                0
                • D dcof

                  In a C# 2010 web form application that uses web form controls, I have a scrollbar used on a panel control. The user would like to be able to retain the scrollbar position while they are on the current web form page. They would like the scrollbar to retain its position until they have pointed to the next web form page. Since I do not know how to accomplish this goal, I am wondering how to accomplish this task. The asp.net markup looks like the following:

                  R Offline
                  R Offline
                  Rajesh Buddaraju
                  wrote on last edited by
                  #15

                  Use Smartnavigation = true property hope it will suits your requirement.

                  S 1 Reply Last reply
                  0
                  • R Rajesh Buddaraju

                    Use Smartnavigation = true property hope it will suits your requirement.

                    S Offline
                    S Offline
                    Sandeep Mewara
                    wrote on last edited by
                    #16

                    Oh yes, I totally forgot about it! :doh:

                    Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]

                    T 1 Reply Last reply
                    0
                    • S Sandeep Mewara

                      Oh yes, I totally forgot about it! :doh:

                      Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]

                      T Offline
                      T Offline
                      Trak4Net
                      wrote on last edited by
                      #17

                      You probably forgot because your first suggestion is the replacement for the deprecated property.

                      [BrowsableAttribute(false)]
                      [ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
                      public bool SmartNavigation { get; set; }

                      http://msdn.microsoft.com/en-us/library/system.web.ui.page.smartnavigation.aspx[^]

                      S 1 Reply Last reply
                      0
                      • T Trak4Net

                        You probably forgot because your first suggestion is the replacement for the deprecated property.

                        [BrowsableAttribute(false)]
                        [ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
                        public bool SmartNavigation { get; set; }

                        http://msdn.microsoft.com/en-us/library/system.web.ui.page.smartnavigation.aspx[^]

                        S Offline
                        S Offline
                        Sandeep Mewara
                        wrote on last edited by
                        #18

                        5! Thanks for bringing back some part of memory. :)

                        Sandeep Mewara [My last article]: Server side Delimiters in ASP.NET[^]

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups