Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 20th, 2007, 01:54 AM
Authorized User
 
Join Date: Aug 2006
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updated Time In C#.net

Hi Friends,
        how to display the updated time(just like in a clock) in a label using c#.net 1.1??
__________________
sumith
 
Old March 20th, 2007, 03:20 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

This can be done using javascript, using the setTimeout method, for your convenience, I have created a sample page, it displays current time in a DIV control, just copy and paste the contents below in a notepad, and save it with .htm extension, and check the result.

<HTML>
    <HEAD>
        <TITLE>Show Time</</TITLE>
        <script language="javascript">
        function ShowTime()
        {

        var Digital = new Date();
        var hours = Digital.getHours();
        var minutes = Digital.getMinutes();
        var seconds = Digital.getSeconds();
        var dn = "AM";
        if (hours > 12){
        dn = "PM";
        hours = hours-12;
        }

        if (hours == 0)
        hours = 12;

        if (minutes <= 9)
        minutes = "0" + minutes;

        if (seconds <= 9)
        seconds = "0" + seconds;

        //change font size here to your desire
        myclock = "<b>Current Time:</br>"+hours+":"+minutes+":"
        +seconds+" "+dn+"</b>"

        document.getElementById("dvTime").innerHTML = myclock;
        setTimeout("ShowTime()",1000)
        } </script>
    </HEAD>
     <body onload="ShowTime()">
     <div id=dvTime></div>
   </body>
</HTML>



Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old March 20th, 2007, 10:40 PM
Authorized User
 
Join Date: Aug 2006
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mike
Thank u for ur help.ur code is working perfectly.
 bye for now..
             take care..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Database not getting updated vsc33 VB How-To 4 May 15th, 2008 10:30 AM
record the time a text box is updated techsp Access 2 August 2nd, 2005 09:51 AM
OPeration must be updated khzahid Classic ASP Basics 1 April 27th, 2005 06:01 PM
This book is scheduled to be updated for ASP.NET 2 englere BOOK: ASP.NET Website Programming Problem-Design-Solution 0 October 28th, 2004 08:39 PM
Updated CR .NET SDK documentation and tutorials David Gadd Crystal Reports 0 April 1st, 2004 04:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.