如何保持自动回发上的滚动位置? [英] How to maintain scroll position on autopostback?
问题描述
如何返回postback
上页面的相同位置.它似乎总是到达页面顶部.
How can I get back to the same position of a page on postback
. It always seems to get to the top of the page.
我尝试使用 maintainScrollPositionOnPostBack = "true"
I've tried using maintainScrollPositionOnPostBack = "true"
但是它不起作用.
推荐答案
我最近也正在寻找它.出现了大量要插入的Javascript,直到我发现以下内容为止:
I've recently looked for this as well. Came up with a load of Javascript to be inserted until I found the following:
在.aspx代码文件的顶部,插入以下内容:
At the top of your .aspx codefile, insert the following:
MaintainScrollPositionOnPostback="true"
因此.aspx中的第一句话开始了
so the very first sentence in your .aspx starts
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
这对我来说很好,而不必添加任何其他代码来使用updatepanels保持滚动条位置
This works just fine for me without having to add any other code for keeping scrollbar positions using updatepanels
这篇关于如何保持自动回发上的滚动位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!