.Net Project/ASP.NET 3.5 Sp1
68장 AJAX 타이머컨트롤(TimerControl)
Magic_kit
2009. 10. 28. 10:43
TimerControl 이란 ??
FrmTimerControl.aspx |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmTimer.aspx.cs"
Inherits="FrmTimer" %>
<!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">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
타이머 컨트롤 <br />
<hr />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
현재시간 :
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html> |
using System;
using System.Web.UI.WebControls;
public partial class FrmTimer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Empty
}
protected void Timer1_Tick(object sender, EventArgs e)
{
//지정된 시간마다 현재 이벤트 핸들러 실행
this.Label1.Text = DateTime.Now.ToLongTimeString();
}
} |