日期:2014-05-18  浏览次数:20522 次

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

前台代码:

  <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 输入时不被刷新
请指教!!!请指教!!!
请指教!!!
请指教!!!



------解决方案--------------------
试试这个

<%@ 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() %&