scroll-position

Maintain scroll position of a div within a page on postback

梦想的初衷 提交于 2019-11-27 14:03:34
问题 I have a div within an aspx page with overflow set to auto. The contents of the div are dynamically created and consists of a list of link buttons. <div id="div1" style="overflow: auto; height: 100%;"> ..... </div> When I scoll down in the div and click on any of the link buttons, the page reload loses the scroll position inside the div and takes me to the top of the div. Is there any way to prevent that? Note that this is for a div inside the page. Page.MaintainScrollPositionOnPostBack()

Scroll Position of div with “overflow: auto”

ぃ、小莉子 提交于 2019-11-27 08:10:51
Given this HTML snippet: <div id="box" style="overflow:auto; width:200px; height:200px; border:1px solid black;"> 1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br> 11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br> 21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br> </div> You (usually) get a black box with a scrollbar that contains the numbers 1 to 30, each in a new row. You can scroll up and down inside of that box. What I need now is a possibility to find out, at which scroll position the box is. Let's just say, each row was 15 pixel high and you scroll down to the

Reset scroll position after Async postback - ASP.NET

*爱你&永不变心* 提交于 2019-11-27 04:19:49
What is the best way to reset the scroll position to the top of page after the an asynchronous postback? The asynchronous postback is initiated from a ASP.NET GridView CommandField column and the ASP.NET update panel Update method is called in the GridView OnRowCommand. My current application is an ASP.NET 3.5 web site. EDIT: I have received excellent feedback from everyone, and I ended using the PageRequestManager method in a script tag, but my next question is: How do I configure it to only execute when the user clicks the ASP.NET CommandField in my GridView control? I have other buttons on

Reset scroll position after Async postback - ASP.NET

一个人想着一个人 提交于 2019-11-26 11:08:12
问题 What is the best way to reset the scroll position to the top of page after the an asynchronous postback? The asynchronous postback is initiated from a ASP.NET GridView CommandField column and the ASP.NET update panel Update method is called in the GridView OnRowCommand. My current application is an ASP.NET 3.5 web site. EDIT: I have received excellent feedback from everyone, and I ended using the PageRequestManager method in a script tag, but my next question is: How do I configure it to only

How do I maintain scroll position in MVC?

廉价感情. 提交于 2019-11-26 07:37:02
问题 Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it\'s not bad. One thing that is really simple in the WebForms world is maintaining the scroll position on a page. All you do is set the MaintainScrollPositionOnPostback property to true. However, in MVC, Im not using postbacks so this will not work for me. What is the standard way of handling this? Edit: Ajax is acceptable, but I was also wondering how you would do it

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

巧了我就是萌 提交于 2019-11-25 22:20:37
问题 I have a long ListView that the user can scroll around before returning to the previous screen. When the user opens this ListView again, I want the list to be scrolled to the same point that it was previously. Any ideas on how to achieve this? 回答1: 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