Save Scroll Position and Return to a Scroll Position.
1.
Add these 2 textbox’s and set their visibility to hidden…
txtScrollPositionFromSessionObject.Attributes.Add("style", "visibility:hidden;")
txtScrollPosition.Attributes.Add("style",
"visibility:hidden;")
2. In the “Not Page.IsPostBack” area, add this code…
txtScrollPositionFromSessionObject.Text =
Val(Session("ScrollPosition") & "")
Session("ScrollPosition") = 0 'reset
3. Add this code ‘onscroll=”scrollPos()” to the scrollable div’s
properties..
<div style="height:500px;
overflow:auto" id="dvCanList" onscroll="scrollPos();">
4. In the Javascript add this code…
<script>
function scrollPos() {
var sp = document.getElementById("dvCanList").scrollTop;
document.getElementById("txtScrollPosition").value = sp;
}
document.getElementById("dvCanList").scrollTop = document.getElementById("txtScrollPositionFromSessionObject").value;
</script>