Hi friends,in this article i will explain about How to Display Current Date and Time on Webpage using ASP.NET using JQuery.
I already explained in the previous articles about How to Bind Nested Gridview from Database in asp.net with C#/VB.NET,Marquee tag or How to Scroll Text From left to right or How to Move the Text in HTML,C#/VB.NET:Save the generated pdf directly to the server directory folder without user prompt in ASP.NET and How to open PDF File in Adobe Reader, not in Browser in ASP.NET using C#/VB.NET
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