Clock : UpdatePanel « ASP.net Controls « ASP.NET Tutorial






<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control.ascx.cs" 
    Inherits="Default" %>

<div>
    <div style="background-color:#EFF3FB;margin:20px;border:solid 4px cyan;">
<%--     <asp:ScriptManager runat="server" ID="ScriptManager1" /> --%>
        <asp:UpdatePanel runat="server" ID="UpdatePanel1">
            <ContentTemplate>
                <asp:Label runat="server" ID="Label1" />
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
        </asp:UpdatePanel>

        <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="1000" />
    </div>
</div>

File: Control.ascx.cs

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;

public partial class Default : System.Web.UI.UserControl
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToLongTimeString(); 
    }
}








3.31.UpdatePanel
3.31.1.Clock
3.31.2.UpdatePanel control is defined dynamically but constructing the tree programmatically
3.31.3.applying partial rendering to a sample ASP.NET form
3.31.4.RegisterAsyncPostBackControl method on the script manager class