您的位置:首页 > 编程语言

代码示例:在多个UpdatePannel使用AJAX.NET TIMER控件

2007-06-10 16:29 776 查看
aspx页面代码:

 




<%...@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXTIMER_INDOUBLEPANNELS._Default" %>




<!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>Untitled Page</title>


</head>


<body>


    <form id="form1" runat="server">


        <asp:ScriptManager ID="ScriptManager1" runat="server" />


        <asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">


        </asp:Timer>


    <div>


        <asp:UpdatePanel ID="upFirst" runat="server" UpdateMode="Conditional">


            <Triggers>


                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />


            </Triggers>


            <ContentTemplate>


                <asp:Label ID="lblFirst" runat="server" Text="upFirst not refreshed yet"></asp:Label>


            
d3bc
</ContentTemplate>


        </asp:UpdatePanel>


    


    </div>


        <asp:UpdatePanel ID="upSecond" runat="server" UpdateMode="Conditional">


            <Triggers>


                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />


            </Triggers>


            <ContentTemplate>


                <asp:Label ID="lblSecond" runat="server" Text="upSecond not refreshed yet"></asp:Label>


            </ContentTemplate>


        </asp:UpdatePanel>


    </form>


</body>


</html>



 后台C#代码:

 


using System;


using System.Data;


using System.Configuration;


using System.Collections;


using System.Web;


using System.Web.Security;


using System.Web.UI;


using System.Web.UI.WebControls;


using System.Web.UI.WebControls.WebParts;


using System.Web.UI.HtmlControls;




namespace AJAXTIMER_INDOUBLEPANNELS




...{


    public partial class _Default : System.Web.UI.Page




    ...{


        protected void Page_Load(object sender, EventArgs e)




        ...{




        }




        protected void Timer1_Tick(object sender, EventArgs e)




        ...{


            lblFirst.Text = "upFirst refreshed at: " +


            DateTime.Now.ToLongTimeString();


            lblSecond.Text = "upSecond refreshed at: " +


            DateTime.Now.ToLongTimeString();


        }


    }


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息