Reset scroll position after Async postback – ASP.NET

As you’re using UpdatePanels you’re going to need to hook into the ASP.NET AJAX PageRequestManager You’ll need to add a method to the endRequest event hooks that are: Raised after an asynchronous postback is finished and control has been returned to the browser. So you’d have something like: <script type=”text/javascript”> Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded); function pageLoaded(sender, args) { … Read more

Maintain/Save/Restore scroll position when returning to a ListView

Try this: // save index and top position int index = mList.getFirstVisiblePosition(); View v = mList.getChildAt(0); int top = (v == null) ? 0 : (v.getTop() – mList.getPaddingTop()); // … // restore index and position mList.setSelectionFromTop(index, top); Explanation: ListView.getFirstVisiblePosition() returns the top visible list item. But this item may be partially scrolled out of view, … Read more