ASP.NET MAZE: ASP.NET 2.0 with AJAX: Maintain Scrollposition for Controls

If you want to hack around the AJAX rendering maze and
experience unexpected scrollbar initialisation when
you try to maintain scrollbar position try this
at the end of your asp page:

<html>...

<div id="DIV1" class="DIV1Scroll" onscroll="SetDivPositionDIV1()">
</div>
...

</form>
    <script type="text/javascript">
      function ScrollPos(){
        var strCook = document.cookie;
        if(strCook.indexOf("!~")!=0){
          var intS = strCook.indexOf("DIV1=!~");
          var intE = strCook.indexOf("~!");
          var strPos = strCook.substring(intS+16,intE);
          document.getElementById("DIV1").scrollTop = strPos;

intS = strCook.indexOf("DIV2=!~");
          intE = strCook.indexOf("~!");
          var strPos = strCook.substring(intS+16,intE);
          document.getElementById("DIV2").scrollTop = strPos;
        }
      }

function SetDivPositionDIV1(){
        var intY = document.getElementById("OrgUnitScroll").scrollTop;
        document.title = intY;
        document.cookie = "DIV1=!~" + intY + "~!";
      }

function SetDivPositionDIV2(){
        var intY = document.getElementById("FinOrgScroll").scrollTop;
        document.title = intY;
        document.cookie = "DIV1=!~" + intY + "~!";
      }

setTimeout("ScrollPos()",250);
    </script>

</body>
</html>

This gives the asp and ajax code time to finish rerender and
init the controls. Then your java code fires after the timeout
and adjusts your scrollbar. This with normal ASP pages and pages using a master page.
It IS a hack but it saves a lot of headaches until ASP.NET and AJAX  becomes better....

ASP.NET and AJAX cause some trouble if you leave the beaten track...