ClevelandSteve
Programmer
I posted this in the ASP.Net forum but it was suggested I post the question here, so here goes. In ASP.Net 2.0 I have a gridview inside of a panel control. The panel has ScrollBars="Auto" so when the height of the gridview exceeds the height of the screen it becomes scrollable. The problem I ran into is when a user scrolls the panel and evokes a row editing event in the gridview, after the postback occurs the panel’s scroll position returns to the top. After searching the internet the favored solution is to use the java script code below and link it to the onscroll event of the panel. But there doesn’t seem to be an onscroll event in a panel or DIV. What am I missing here?
<script type="text/javascript">
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.getElementById("grdWithScroll").scrollTop =strPos;
}
}
function SetDivPosition(){
var intY = document.getElementById("grdWithScroll").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";
}
</script>
<script type="text/javascript">
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.getElementById("grdWithScroll").scrollTop =strPos;
}
}
function SetDivPosition(){
var intY = document.getElementById("grdWithScroll").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";
}
</script>