title: How to create a running current DateTime in a Label
body: <p>I'm very new to ASP.net C#. I managed to search online on how to display the current date inside a C# Label. For some reason the <strong>Page_Load</strong> needs to be implemented as a script in the webform and does not work if implemented in the codebehind. My problem is that the time only changes when the page is refreshed. I need the time to change with the system time as it changes. Please help me. Thanks in advance.</p>
  
  <p>Here's my code to get the current Date and Time :</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StaffTravelInterface.aspx.cs" Inherits="StaffTravel.StaffTravelInterface" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;script runat="server"&gt;
      protected void Page_Load(object sender, EventArgs e)
      {
          DateTime dt = DateTime.Now;
          string Day = dt.Day.ToString();
          string Month = dt.ToString("MMM");
  
          string Hour = dt.Hour.ToString();
          string Minute = dt.ToString("mm");
          timeNow.Text = Day + " " + Month + "   " + Hour + ":" + Minute;
      }
  &lt;/script&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head runat="server"&gt;
          &lt;style type="text/css"&gt;
              #time
              {
                  margin-top:-67px;
                  float:right;
              }
  
              #main
              {
                  position:static;
                  max-width:100%;
              }
  
              #head
              {
                  width:100%;
              }
          &lt;/style&gt;
  
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;div id="main"&gt;
              &lt;div id="head" style="background-image:url('../Pics/Header.png'); background-repeat:no-repeat; height:100px"&gt;
              &lt;/div&gt;
  
              &lt;div id="time"&gt;
                  &lt;asp:Label ID="timeNow" runat="server" Text="" style="color:#fea171; font-family:Arial Black; font-weight:bold; font-size:32px"&gt;&lt;/asp:Label&gt;
                  &amp;nbsp;
              &lt;/div&gt;
  
              &lt;div id="bg2"&gt;
                  &lt;img src="Pics/slide.png" style="width:100%; height:100%" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>