C# code :
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TextBox7.Attributes.Add("onfoucs", "javascript:calendar();"); } }
HTML code :
<head runat="server"> <title>故障登记</title> <script type="text/javascript" language="javascript" src="/calendar.js"></script> </head> <body style="font-family: Times New Roman; background:#ccffcc;text-align: center;" > <form id="form1" runat="server"> <div style="text-align: center"> <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox> 注意:显示时要是取用了数据库默认值,数据库中的默认值是将年月日时分秒都显示出来,可用方法TrimEnd()是截取年月日,不显示时分秒
如果不加以截取,首次修改数据时会报错!