小编Joh*_*etz的帖子

ASP页面滚动到UpdatePanel更新的顶部

我遇到一个问题,我有一个使用计时器触发以使用新点更新ASP图的UpdatePanel(本质上是该指南,网址http://www.4guysfromrolla.com/articles/121609-1.aspx,在“创建实数时间表”)。我遇到一个问题,每当计时器计时时,整个页面就会滚动到顶部。计时器计时时如何保持页面中的滚动位置?我已经尝试了http://www.4guysfromrolla.com/articles/111704-1.aspx上的说明以及其他几种类似的JavaScript解决方案,但是只要计时器计时,x和y变量就会消失。

码:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="scmManager" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="updRealtimeChart" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <asp:Chart ID="chtRandomData" ...></asp:Chart><br />
            <asp:Repeater ID="valueRepeater"...></asp:Repeater>
            <asp:Label ID="errorLabel" Font-Bold="true" Font-Size="Larger" ForeColor="Firebrick" BackColor="Khaki" runat="server"></asp:Label>
            <asp:Timer ID="tmrRefreshChart" runat="server" Interval="300"></asp:Timer>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="periodUpdate" />
        </Triggers>
    </asp:UpdatePanel>
    ...etc rest of the page...
Run Code Online (Sandbox Code Playgroud)

编辑:在后面的代码中,我尝试了此操作以检查发生了什么:

public partial class _Default : System.Web.UI.Page
{
    public int count = 0;
    protected void Page_Init(object …
Run Code Online (Sandbox Code Playgroud)

asp.net updatepanel asp.net-ajax

2
推荐指数
1
解决办法
7378
查看次数

标签 统计

asp.net ×1

asp.net-ajax ×1

updatepanel ×1