在 ASP.NET 中的回发时维护水平和垂直 ScrollPosition
编码采用 ASP.NET C#。
我有一个 gridview,有 1000 条记录,我正在内联编辑其中一行。
单击“更新”时,我希望我的网格位于回发发生之前的确切 xy 位置。
如果您正在考虑使用 Page 指令,MaintainScrollPositionOnPostback="true"
,不,它对我不起作用
什么是最优化的方法?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 UpdatePanel 控件来包装网格。
另一种方法是使用 ajax,就像使用 jqGrid 组件一样。
Using the UpdatePanel control to wrap your grid.
Another way would be to use ajax instead like using the jqGrid component.
您可以使用 AJAX UpdatePanel 来避免重新加载整个页面。即使
MaintainScrollPositionOnPostback
由于某种原因无法正常工作,该功能也能正常工作。You could use an AJAX UpdatePanel to avoid reloading the whole page. That will work even when
MaintainScrollPositionOnPostback
for some reason does not.创建一个 js 方法来将页面的当前滚动位置记录到隐藏的服务器控件。您可以将其设置为每个更新按钮、onscroll 或在您手动滚动到编辑行之后和回发发生之前触发的任何其他内容上的处理程序。
在服务器处理期间,生成将恢复滚动位置的js代码。将其注册为启动脚本。
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.