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

如何在TextBox中显示系统日期
我想将系统日期显示在一个TextBox控件中,怎么写代码?使用的using指令是什么?编程环境是.net,C#语言。
多谢

------解决方案--------------------
TextBox1.Text = DateTime.Now.ToString();
------解决方案--------------------
TextBox1.Text = DateTime.Now.ToString(yymmdd);
------解决方案--------------------
或者﹕
System.Globalization.CultureInfo sDtInfo = new System.Globalization.CultureInfo( "en-GB ", true);
TextBox2.Text = DateTime.Now.ToString( "dd MMM yyyy ",sDtInfo);
------解决方案--------------------
<script language= "JavaScript ">
function TOfunc()
{
TO = window.setTimeout( "TOfunc() ", 1000 );
var today = new Date();
document.Form1.disp.value = today.toLocaleString();
document.getElementById( 'lable1 ').innerText =today.toLocaleString();
}
setTimeout( 'TOfunc() ', 1000 );
</script>


<body MS_POSITIONING= "GridLayout ">
<form id= "Form1 " method= "post " runat= "server ">
<INPUT style= "Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 88px " type= "text " name= "disp ">
<DIV style= "DISPLAY: inline; Z-INDEX: 102; LEFT: 136px; WIDTH: 104px; POSITION: absolute; TOP: 152px; HEIGHT: 19px "
ms_positioning= "FlowLayout " id= "lable1 "> Label </DIV>
<asp:Button id= "Button1 " style= "Z-INDEX: 103; LEFT: 416px; POSITION: absolute; TOP: 200px " runat= "server "
Text= "Button "> </asp:Button>
</form>
</body>
------解决方案--------------------
TextBox1.Text = DateTime.Now.ToString();
就可以了
------解决方案--------------------
document.Form1.disp.value = today.toDateString ();
晕,楼主,我那个方法不行吗?
我试了试,都可以的,你还想怎么样?
------解决方案--------------------
txtSetupDate.Text = DateTime.Now.ToShortDateString();