Posts tagged ‘Gridview Position’

Maintain GridView scroll position on postback

Copy blow code and paste it in your page to maintain Gridview Scroll position during postback event fire.

 

<script type=”text/javascript”>

var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get(‘scrollDiv’).scrollLeft;
yPos = $get(‘scrollDiv’).scrollTop;
}
function EndRequestHandler(sender, args) {
$get(‘scrollDiv’).scrollLeft = xPos;
$get(‘scrollDiv’).scrollTop = yPos;
}

</script>