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. Page goes back to top everytime it's posted back

Page goes back to top everytime it's posted back

Scheduled Pinned Locked Moved ASP.NET
help
6 Posts 6 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.
  • A Offline
    A Offline
    AesopTurtle
    wrote on last edited by
    #1

    I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

    H A W A S 5 Replies Last reply
    0
    • A AesopTurtle

      I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

      H Offline
      H Offline
      hakanaktan
      wrote on last edited by
      #2

      I think, setting Smart Navigation property of page to "True" will handle your problem. --junior coder--

      1 Reply Last reply
      0
      • A AesopTurtle

        I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

        A Offline
        A Offline
        Alsvha
        wrote on last edited by
        #3

        check this page out: http://aspnet.4guysfromrolla.com/articles/111704-1.2.aspx edit:forgot link --------------------------- 127.0.0.1 - Sweet 127.0.0.1

        1 Reply Last reply
        0
        • A AesopTurtle

          I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

          W Offline
          W Offline
          Wyxlwiis
          wrote on last edited by
          #4

          well using smart navigation only works in IE a better way is to use the onscroll event and write the scroll y pos to a hiddenfield and let the body onload event call a method that sets the value of scroll y pos to the hiddenfield value, this works in IE and Mozilla browsers however not in Opera since they have removed the onscroll event Wyx :cool:

          1 Reply Last reply
          0
          • A AesopTurtle

            I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Hi use this javascript for setting the page fixed on page postback 1)place this below script in betwwen your page head tags

            function ScrollIt(){
                window.scrollTo(document.Form1.PageX.value, document.Form1.PageY.value);
                }
            function setcoords(){
                var myPageX;
                var myPageY;
                if (document.all){
                    myPageX = document.body.scrollLeft;
                    myPageY = document.body.scrollTop;
                    }
                else{
                    myPageX = window.pageXOffset;
                    myPageY = window.pageYOffset;
                    }
                document.Form1.PageX.value = myPageX;
                document.Form1.PageY.value = myPageY;
                }
            
            1. add onscroll and onload events of your page body3) add this below html text boxes in between your form tags then check out Bye Kalyan
            1 Reply Last reply
            0
            • A AesopTurtle

              I have a page containing a datagrid with the first column selectable. If a record is selected, information for that record will be shown on the right. The page is quite long due the large amount of information (thus, long list of data in the datagrid). The problem is when i select a record at the bottom (or lower than a page), the page brings me back to the top of the page. Actually, this is not really a problem. It's just annoying/not working as i want it to. So i wonder if there's a way to set a focus to a specific control e.g. the clicked record or any better way to make it stay where i want. KiT

              S Offline
              S Offline
              smiling4ever
              wrote on last edited by
              #6

              Put this code inside the html head tags of the page that you are having problems with: window.onload = function(){ var strCook = document.cookie; if(strCook.indexOf("!~")!=0){ var intS = strCook.indexOf("!~"); var intE = strCook.indexOf("~!"); var strPos = strCook.substring(intS+2,intE); document.body.scrollTop = strPos; } } function SetScrollPosition(){ var intY = document.body.scrollTop; document.title = intY; document.cookie = "yPos=!~" + intY + "~!"; } window.onscroll = SetScrollPosition; HTH Royal Systems For web design and network solutions

              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