Wednesday, 1 July 2015

Display Current Date Time on WebSite Using in JavaScript Asp.Net C#

No comments    
categories: , , ,
Display Current Date Time on WebSite

Label Display Current Date and Time  Using JavaScript timeout Set Interval Update  Every Seconds in Asp.Net C#.

                    Download Coding 
                              Download

                       DEMO

                   HTML CODING

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Display Current Date Time on WebSite Using in JavaScript Asp.Net </title>
<script type="text/javascript">
    function DateTime() {
       window.setTimeout("DateTime()", 1000);     
       var TD = new Date();    
       document.getElementById("Label1").innerHTML = TD.toLocaleString();      
     }
</script>
</head>
<body onload="DateTime()" >
<form id="form1" runat="server">  
    <asp:Label ID="Label1" ForeColor="Red"  Font-Size="X-Large" runat="server"></asp:Label>
    <br />
    <asp:Label ID="Label2" ForeColor="Red"  Font-Size="X-Large" runat="server" ></asp:Label>
</form>
</body>

</html>

                      C# CODING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 Label2.Text =  String.Format("{0}"DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss Sec"));
    
    }
      
}








     








0 comments:

Post a Comment