Scrollbar position on a panel web server control
-
Anyone know how to get / set the position of the scrollbars on a panel web server control. Thus I can remember where a user was in a given panel, if they had used the scroll bars??? Many thanks
-
Anyone know how to get / set the position of the scrollbars on a panel web server control. Thus I can remember where a user was in a given panel, if they had used the scroll bars??? Many thanks
yourpanleid.scrollTop, yourpanelid.scrollLeft. for your panel id, refer your page html which is rendered. note, these two methods are client side methods. you can save them in a hidden field. i save them in a hidden textbox by scrollchange() method. and set them by changescroll() method: function scrollchange() { document.getElementById("txtScroll").value=document.body.scrollTop; document.getElementById("txtScroll").value+=";"+document.body.scrollLeft; } function changescroll() { if(document.getElementById("txtScroll").value != "") { parts = document.getElementById("txtScroll").value.split(";"); document.body.scrollTop = parseInt(parts[0]); document.body.scrollLeft = parseInt(parts[1]); } } Thanks Rastgar
-
yourpanleid.scrollTop, yourpanelid.scrollLeft. for your panel id, refer your page html which is rendered. note, these two methods are client side methods. you can save them in a hidden field. i save them in a hidden textbox by scrollchange() method. and set them by changescroll() method: function scrollchange() { document.getElementById("txtScroll").value=document.body.scrollTop; document.getElementById("txtScroll").value+=";"+document.body.scrollLeft; } function changescroll() { if(document.getElementById("txtScroll").value != "") { parts = document.getElementById("txtScroll").value.split(";"); document.body.scrollTop = parseInt(parts[0]); document.body.scrollLeft = parseInt(parts[1]); } } Thanks Rastgar
Hi Rastgar Many thanks for the pointer - FYI my implementation of the initialisation, is like this: (c#) StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append("var szValue = document.getElementById('Panel1');"); sb.Append("szValue.scrollTop = 146;"); sb.Append("szValue.scrollLeft = 182;"); sb.Append(""); ClientScript.RegisterStartupScript(typeof(string), "Init", sb.ToString()); This then just runs at startup. And of course I can harvest the values from the user by any number of means Once again, many thanks regards, John