Monday, 28 October 2013

JQuery:How to Display Current Date and Time on Webpage using ASP.NET

Hi friends,in this article i will explain about How to Display Current Date and Time on Webpage using ASP.NET using JQuery.
In ASP.NET design page write the following code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery Display Current Time on Webpage using Asp.net</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" language ="javascript" type ="text/javascript" >
</script>
   <script type="text/javascript">
       $(document).ready(function () {
           ShowDateAndTime();
       });
       function ShowDateAndTime() {
           var dt = new Date();
          $("#lblTime").html(dt.toLocaleDateString() + "  " + dt.toLocaleTimeString());
           window.setTimeout("ShowDateAndTime()", 1000); // Here 1000(milliseconds) means  1 Second
       }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>The Current Date and Time is
    <asp:Label ID="lblTime" runat="server" style="Color:Green;"></asp:Label>  
    </div>
    </form>
</body>
</html>




   The output of the above code as shown in the below figure..Actually it showning current time with seconds.Check it once.
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter  on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on  RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog  for more articles."

No comments:

Post a Comment

© 2012-2014 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.