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

编程入门 行业动态 更新时间:2024-10-27 19:21:52
本文介绍了ASP页面滚动到顶部的UpdatePanel上更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个问题,我有一个使用一个计时器来触发更新与新百分点ASP图(在本质上的 www.4guysfromrolla/articles/121609-1.aspx 下的创建实时图表)。我在哪里,只要计时器滴答声,整个页面滚动到顶部的问题。我怎样才能保持当计时器滴答的页面滚动位置?我试着在 www.4guysfromrolla/articles/111704-的说明1.aspx 和其他一些类似的JavaScript的解决方案,但在x和y的变量越来越消灭每当计时器刻度。

I am having a problem where I have an UpdatePanel that uses a timer to trigger to update an ASP graph with new points (essentially the guide at www.4guysfromrolla/articles/121609-1.aspx under "Creating Real Time Charts"). I'm having a problem where whenever the timer ticks, the entire page scrolls to the top. How can I maintain the scroll position in the page when the timer ticks? I've tried the instructions at www.4guysfromrolla/articles/111704-1.aspx and several other similar JavaScript solutions, but the x and y variables are getting wiped out whenever the timer ticks.

code:

<%@ 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...

编辑:在code后面,我已经试过这种检查是怎么回事:

In the code behind, I've tried this to check what is going on:

public partial class _Default : System.Web.UI.Page { public int count = 0; protected void Page_Init(object sender, EventArgs e) { Page.MaintainScrollPositionOnPostBack = true; count++; } protected void Page_Load(object sender, EventArgs e) { errorLabel.Text += count; ... }

当运行此,在UpdatePanel连续增加了一个1到errorLabel,表明在Page_Load和Page_Init功能仅发生一次,但更新面板仍移位滚动位置。

When I run this, the UpdatePanel continuously adds a "1" to the errorLabel, indicating that the Page_Load and Page_Init functions are only occurring once, but the update panel is still shifting the scroll position.

推荐答案

这看起来像一个熟悉的.NET的Bug。在Timer控件设置的ClientIDMode =自动应该修复它。

This looks like a familiar .NET Bug. Setting ClientIDMode=Auto on the Timer control should fix it

更多推荐

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

本文发布于:2023-11-25 00:18:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   ASP   UpdatePanel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!