Thursday, August 26, 2010

asp.net date time example: how to get system date time





<%@ Page Language="C#" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        DateTime now = DateTime.Now;
        Label1.Text = "System DateTime[Now]: " + now.ToString();
        Label1.Text += "<br />System DateTime[ToDay]: " + now.ToLongDateString();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net date time example: how to get system date time</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Green">asp.net example: DateTime.Now</h2>
        <asp:Label
             ID="Label1"
             runat="server"
             Font-Size="Large"
             ForeColor="PaleVioletRed"
             Font-Bold="true"
             Font-Italic="true"
             >
        </asp:Label>
        <br /><br />
        <asp:Button
             ID="Button1"
             runat="server"
             OnClick="Button1_Click"
             Font-Bold="true"
             Text="Get System DateTime[Now]"
             ForeColor="Magenta"
             />
    </div>
    </form>
</body>
</html>

No comments: