Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to create a clock on my ASP.NET page that display a time without refreshing the page
Posted
Updated 17-Sep-11 0:53am
v2

Depending on what you are actually going to use it for, wouldn't a simple javascript timer work - see this[^] for example
 
Share this answer
 
C#
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function TimeToShow() {
            var dt = new Date();            
            var la = document.getElementById("<%= Timer.ClientID %>");
             la.innerHTML = dt.toLocaleTimeString();
            window.setTimeout(TimeToShow, 1000);          
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:label id="Timer" runat="server" text="Timer">
    <asp:button id="btnStart" runat="server" text="Start"/>    
    </div>
    </form>
</body>
</html>
 
Share this answer
 
v2
 
Share this answer
 
You try this link

Only time In Asp.net[^]
 
Share this answer
 
By Jquery or Ajax u can show Time
 
Share this answer
 
Search as Convas control in w3school.com
lot of option are available on net....
 
Share this answer
 
Comments
CHill60 21-Jul-15 5:34am    
"lot of option are available on net...." - yes there are, including the other 7 solutions that were posted over 3 years ago. If you are not going to add useful information then I advise you to avoid answering old posts in this way

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900