Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have gridView and records can be long. I have command field to update records. When i click "Edit" the command button makes javascript postback.
JavaScript
javascript:__doPostBack('gridSubCategories$ctl02$ctl00','');

Even i set MaintainScrollPositionOnPostback="true", after postback page is not scrolling previous point. What can i do?
Posted
Updated 4-Feb-11 4:10am
v2

1 solution

Put the grid inside a panel (rather than scrolling the grid itself) and the following in the head section of the page. This is set for using a MasterPage, but you can remove the "ctl00_MainContentPlaceHolder_" prefix for a regular page.

XML
<script type="text/javascript" language="javascript">
        window.onload = function () {
                var strCook = document.cookie;

                if (strCook.indexOf("!~") != 0) {
                        var intS = strCook.indexOf("!~");
                        var intE = strCook.indexOf("~!");
                        var strPos = strCook.substring(intS + 2, intE);
                        document.getElementById("ctl00_MainContentPlaceHolder_pnlFindings").scrollTop = strPos;
                }

        }
</script>
<script type="text/javascript" language="javascript">
        function SetDivPosition() {
                var intY = document.getElementById("ctl00_MainContentPlaceHolder_pnlFindings").scrollTop;
                document.cookie = "yPos=!~" + intY + "~!";
        }
</script>


In the Panel, you'll need:
onscroll="SetDivPosition()"

That should do it for you. Works for me, anyway.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900