Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

how to add digital clock in asp.net master page. can anyone give me sample source codes.
I want to add my application.

Thanks

Regards,

Manuel.
Posted
Comments
thatraja 13-Feb-14 3:12am    
We don't have any code. You should learn or atleast search Google.

try this in asp.net:-
XML
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
<asp:Label ID="lblcurrenttime" runat="server" Text=""></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>


in code behind c# code:-
C#
protected void Page_Load(object sender, EventArgs e)
{
   System.Threading.Thread.Sleep(100);
   string currenttime = DateTime.Now.ToLongTimeString();
   lblcurrenttime.Text = currenttime;
}


desired o/p:-
5:15:33PM

If you want jquery digital clock then refer:-
http://joaquinnunez.cl/jquery-clock-plugin/[^]
http://www.aspdotnet-suresh.com/2013/04/8-best-jquery-clock-plugins-analog.html[^]
http://www.jquery4u.com/plugins/10-cool-jquery-clock-tutorials-analog-digital/[^]
 
Share this answer
 
v2
 
Share this answer
 
 
Share this answer
 
Try it :
Simple and Easy one :
XML
<input type="text" id="clock"/>
  <script type="text/javascript">
    setInterval("settime()", 1000);

    function settime()
    {
      var dateTime = new Date();
      var hour = dateTime.getHours();
      var minute = dateTime.getMinutes();
      var second = dateTime.getSeconds();

      if (minute < 10)
        minute = "0" + minute;

      if (second < 10)
        second = "0" + second;

      var time = "" + hour + ":" + minute + ":" + second;

      document.getElementById("clock").value = time;
    }
  </script>
 
Share this answer
 
There Are Many Others Why Are You Pointing Towrds To Me????

Sorry
 
Share this answer
 
Simply YOu Can Refer This
..
XML
<script language="javascript" type="text/javascript">
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
// add a zero in front of numbers<10
m = checkTime(m);
s = checkTime(s);
document.getElementById('txtt').value = h + ":" + m + ":" + s;
t = setTimeout('startTime()', 500);
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
</script>


..
Thanks..
 
Share this answer
 
Comments
Bernhard Hiller 12-Sep-14 3:13am    
Why do you "answer" old question which already have an accepted answer?

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