So, I learned a bit. Someone please tell me if this is correct.
DNN already preserves your scroll position on postback. However it appears to me that this only works in Firefox and Opera. I can't seem to get it to work in IE 6. Is that true? Is there a way to get this to work in IE and I'm just missing it?
FYI, preserving scroll position on postback is already built in to Default.aspx and js/dnncore.js.
Default.aspx has hidden field to store scroll position:
<INPUT ID="ScrollTop" runat="server" NAME="ScrollTop" TYPE="hidden">
Default.aspx registers ONSCROLL event handler as:
ONSCROLL="__dnn_bodyscroll()"
in js\dnncore.js
function __dnn_bodyscroll()
{
var oF=document.forms[0];
if (__dnn_ClientAPIEnabled() && __dnn_m_bPageLoaded)
oF.ScrollTop.value=dnn.dom.getByTagName("body")[0].scrollTop;
}
This function in the onscroll event, if the client API is enabled and the page load has completed, saves the
ScrollTop value in the Form hidden field called ScrollTop. On a Postback this value will be submitted.
In Default.aspx.vb, in the page_load, if the ScrollTop hidden field has a value, DNN regsiters an Onload event handlers to call the javascript function __dnn_setScrollTop(). This function finds the ScrollTop saved value from the Hidden field then sets the Body's scrolltop to the saved value:
function __dnn_setScrollTop(iTop)
{
if (__dnn_ClientAPIEnabled())
{
if (iTop == null)
iTop = document.forms[0].ScrollTop.value;
var sID = dnn.getVar('ScrollToControl');
if (sID != null && sID.length > 0)
{
var oCtl = dnn.dom.getById(sID);
if (oCtl != null)
{
iTop = dnn.dom.positioning.elementTop(oCtl);
dnn.setVar('ScrollToControl', '');
}
}
dnn.dom.getByTagName("body")[0].scrollTop = iTop;
}
}