• 全部
  • .NET Framework
  • ASP
  • Web Services
  • .NET互联网桌面应用
  • VB
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • AppLauncher
  • 问答

多个UpdatePanel,只定时刷新其中一个,怎么做?急!急!

jianxiake318 2012-02-16 05:59:16

前台代码:

<div style="height: 143px; width: 545px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></asp:Label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer2" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick">
</asp:Timer>
<asp:Timer ID="Timer2" runat="server" Interval="5000000" OnTick="Timer2_Tick">
</asp:Timer></div>


后台代码:

protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
GetDate();
}
}

private void GetDate()
{


}

protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "UpdatePanel1 更新于: " + DateTime.Now.ToLongTimeString();
}
protected void Timer2_Tick(object sender, EventArgs e)
{
Label2.Text = "UpdatePanel2 更新于: " + DateTime.Now.ToLongTimeString();
}

想要UpdatePanel 定时更新,UpdatePanel2 输入时不被刷新
请指教!!!请指教!!!
请指教!!!
请指教!!!

...全文
252 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
CodingR 2012-02-17
试试这个

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DemoCSDN.aspx.cs" Inherits="DemoCSDN" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Timer ID="Timer1" runat="server" Interval="1">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<%=DateTime.Now.ToString() %>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DemoCSDN : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Timer1_Tick(object sender, EventArgs e)
{
int tickcount = 0;
if (ViewState["TickCount"] != null)
{
tickcount = (int)ViewState["TickCount"];
}
tickcount++;
ViewState["TickCount"] = tickcount;
if (tickcount > 10)
{
Timer1.Enabled = false;
}

}
}
回复
骑猪看海 2012-02-17
拖个Timer进去设置下即可,话说我可没用过,自己研究下,用JQ多方便啊
回复
jianxiake318 2012-02-17
想要UpdatePanel 定时更新,UpdatePanel2 输入时不被刷新
请指教!!!请指教!!!
请指教!!!
请指教!!!

回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2012-02-16 05:59
社区公告
暂无公告