日期:2014-05-19  浏览次数:20542 次

在aspx页面中如何显示日期和时间?
<%@   Page   Language= "C# "   %>
<script   runat= "server ">
        void   Button1_Click(Object   sender,   EventArgs   e)
        {
                HelloWork.Text   =   "Clicked   at   "   +   DateTime.Now.ToString();
        }
</script>
<html>
<head>
    <title> Single-File   Page   Model </title>
</head>
<body>
    <form   id= "Form1 "   runat= "server ">
        <div>
              <asp:Label   id= "HelloWork "   runat= "server "   Text= "StudyLesson001 "   BackColor= "Transparent "   BorderColor= "#8080FF "   Font-Bold= "True "   Font-Size= "Smaller "> </asp:Label>
              <br>
              <asp:Button   id= "Button1 "   runat= "server "   onclick= "Button1_Click "   Text= "点击我改变状态 "   Font-Bold= "True "   Font-Size= "Smaller "> </asp:Button>
        </div>
    </form>
</body>
</html>
-------------------------------------
上面这个是可以运行出时间的,但我想使用代码分离显示时间
-----------------------------------
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;

public   partial   class   Default3   :   System.Web.UI.Page
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {

        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                Label1.Text   =   "lookme   "   +   DateTime.Now.ToString();
        }
}

---------------------------------
<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "Default3.aspx.cs "   Inherits= "Default3 "   %>

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

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
          &nbs