Javascript to display time on Web page

 Rate It (3)

Javascript to display continuous time on the Web page. By continuous it means that it will be displayed second by second.

    <script type="text/javascript">
        function ShowTime()
        {
            var dt = new Date();
            document.getElementById("<%= TextBox1.ClientID %>").value = dt.toLocaleTimeString();
            window.setTimeout("ShowTime()", 1000);
        }
       
            
    </script>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


If you are using normal Webform then it can be called on Body load event. If you are using MasterPage then it can be called within ContentTemplate at the end afte all the controls will be rendered.

Revision number 1, Saturday, February 16, 2008 5:45:41 AM by
This is not the most up to date version of this article. The most recent version can be found here.

Comments

Related Articles

Visual Studio 2008

Visual Studio 2008is theversion of Visual Studio which comes with the .NET Framework 3.5. It was released to MSDN subscribers on 19 November 2007 alongside the.NET Framework 3.5. Visual Studio 2008 can target developmentin .NET Framework versions 2.0, 3.0

Javascript to add bookmark option on your website

If it is required to add a facility on the webpage that users can click a button on the website and it will open up bookmark option. Following is the code that will perform this task. html>body>SCRIPT LANGUAGE="JavaScript"> function bookmark

Check/Uncheck checkboxes in GridView using JavaScript

Thequestion regarding how to check/uncheck CheckBoxes within a GridView control using JavaScript has been asked many times. Hereis aquick reference you can follow. Firstwe havethe .aspx markup. script type="text/javascript"> function SelectAll

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. mbanavige (5)
  2. SGWellens (4)
  3. maartenba (2)
  4. rami_nassar (2)
  5. stiansol (2)
  6. MisterFantastic (2)
  7. satish1.v (1)
  8. raklos (1)
  9. mosessaur (1)
  10. Jos Branders (1)

Advertise Here

Microsoft Communities
Page view counter