Maintain horizontal and vertical ScrollPosition on Postback in ASP.NET

孤街浪徒 提交于 2020-01-13 20:39:47

问题


The coding is in ASP.NET C#.
I have a gridview, with say 1000 records and I am inline editing one of the rows.
On Clicking Update, I would like my Grid to be on the exact x y position it was on before the postback happened.
If you are thinking along the lines of using the Page directive, MaintainScrollPositionOnPostback="true", no, it didnt work for me
What is the most optimal method?


回答1:


Using the UpdatePanel control to wrap your grid.

Another way would be to use ajax instead like using the jqGrid component.




回答2:


You could use an AJAX UpdatePanel to avoid reloading the whole page. That will work even when MaintainScrollPositionOnPostback for some reason does not.




回答3:


create a js method to record the current scroll position of the page to a hidden server control. you could set this up as a handler on each update button, or onscroll, or anything else that will fire after you manually scroll to your edit row and before the postback occurs.

during server processing, generate js code that will restore the scroll position. register this as a startup script.



来源:https://stackoverflow.com/questions/3448694/maintain-horizontal-and-vertical-scrollposition-on-postback-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!