Monday, 30 April 2012

ASP.net Maintain scrollbar position after asynchronous post back


In order to maintain scrollbar position after asynchronous post back it is not at all enough to include the MaintainScrollPositionOnPostBack in the page directive alone. We need to include the below JavaScript code just below ScriptManager tag. Because during asynchronous post back, only code within the ScriptManager tag will be executed within aspx page and after that the below JavaScript will be executed and it maintain the scrollbar position.


1. First include the maintain scroll bar position as in the below code.
<pages maintainScrollPositionOnPostBack="true" />

2. Second Include the JavaScript code below the ScriptManager tag

 <script type="text/javascript">
       window.scrollTo = function () { }
</script>

No comments:

Post a Comment