Question scroll position of a multi-select listbox using javascript not working in production

fatoldpig

New member
Joined
Nov 15, 2012
Messages
2
Programming Experience
Beginner
Hi, my post here.
I'm trying to maintain the scroll position of a multi-select listbox using javascript. It works when I run it in Visual Studio 2010 environment but not working in the production environment, it resets back to the top. Here's my code in Page_Load

my pages have master page.

lstProduct.Attributes.Add("onclick", "GetScrollPositionlstProduct();") 'get scroll position

If (Not ClientScript.IsStartupScriptRegistered("lstProduct")) Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "lstProduct", "SetScrollPositionlstProduct();", True) 'set scroll position
End If


javascript:
function GetScrollPositionlstProduct() {
document.getElementById(
'ctl00_mainContent_iScollToplstProduct').innerText = document.getElementById('ctl00_mainContent_lstProduct').scrollTop;
}

function SetScrollPositionlstProduct() {
if (document.getElementById('ctl00_mainContent_lstProduct') != null) {
document.getElementById(
'ctl00_mainContent_lstProduct').scrollTop = document.getElementById('ctl00_mainContent_iScollToplstProduct').value;
}
}

please help. thanks

 
Back
Top