OK, I think I got it. The idea here is I want to save the scroll position of a DIV. I use a Session variable to store the scroll state because I expect the user to go to other pages and refresh the screen, when they come back I want to set the scroll back to where they left it.
In .aspx I place the following JavaScript functions:
PHP Code:
<script language="javascript">
function saveScrollState() {
scrollPx = ListManDataTable.scrollTop;
}
function restoreScrollState() {
ListManDataTable.scrollTop = scrollPx;
}
</script>
Then I invoke them on the body tag's onLoad and onUnload
PHP Code:
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" onUnload="javascript:saveScrollState();" onLoad="javascript:restoreScrollState();">
I also use a hidden variable, scrollPx, referenced in the javascript functions:
PHP Code:
<form id="dataForm" method="post">
<input type="hidden" name="scrollPx" id="scrollPx" runat="server">
Also, let us not forget the <DIV> containing the repeater where we want our scroll state preserved:
PHP Code:
<div id="ListManDataTable" style="Z-INDEX:1; VISIBILITY:visible; OVERFLOW:auto; WIDTH:690px; POSITION:absolute; HEIGHT:360px">
<asp:Repeater ...>
</asp:Repeater>
</div>
Now for the codebehind:
Code:
override protected void Page_Load( object sender, System.EventArgs e )
{
string strJScript = "<SCRIPT LANGUAGE=javascript>\n";
strJScript += "hidScrollPx = " + Session["patListContentScrollPos"] + ";";
strJScript += "</SCRIPT>";
Page.RegisterClientScriptBlock("XYZ", strJScript);
}
override protected void Page_Unload()
{
Session["patListContentScrollPos"] = hidScrollPx;
}
Also added the property:
Code:
protected int hidScrollPx;
I think that will do it. (Might need to clean up the JavaScript references a little though).