Tuesday 7 May 2013

Widgets

Get Date and Time From System in Asp.net.


<%@ 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>Get Date And Time From The System</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Blue">Date & Time </h2>
        <asp:Label ID="Label1" runat="server" Font-Size="22px" ForeColor="Green" Font-Bold="true" Font-Italic="false" >
        </asp:Label>
        <br /><br />
        <asp:Button ID="Button1"  runat="server" OnClick="Button1_Click" Font-Bold="True"  Text="Date & Time"
             ForeColor="black" Font-Size="Large"/>  
    </div>
    </form>
</body>
</html>




Demo:-

0 comments:

Post a Comment