如何保持自动回发上的滚动位置? [英] How to maintain scroll position on autopostback?

查看:91
本文介绍了如何保持自动回发上的滚动位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何返回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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆