How to Create degital watch in Webpage in As.net



In this example we will create digital watch in our webpage so each and every time we can see time in our webpage many client application or project I have seen like this control in Web Application or else Windows Application. So let’s start we will create our watch in our webpage.

HTML CODE:

<div style="margin-left:160px;font-size:x-large">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Timer ID="tmrUpdate" runat="server" Interval="1000" OnTick="tmrUpdate_Tick">
        </asp:Timer>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="tmrUpdate" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="lblTime" runat="server" Text=""></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

CODE BEHIND:

protected void Page_Load(object sender, EventArgs e)
        {
            lblTime.Text = System.DateTime.Now.ToString("T");
            ////DateTime.Now.ToString("T");
        }
protected void tmrUpdate_Tick(object sender, EventArgs e)
        {
            lblTime.Text = System.DateTime.Now.ToString("T");
        }

Related Posts

Previous
Next Post »

Thanks for comments.....