如何在单击按钮的文本框中插入日期时间? [英] how to insert datetime in textbox whn clicked to button?

查看:108
本文介绍了如何在单击按钮的文本框中插入日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我单击按钮并显示到文本框时插入默认日期时间?

hi how to insert Default date time when i clicked to button and show into textbox?

推荐答案

简单

在按钮Click
中编写此代码
Simple

Write this code in the Button Click

textBox1.Text = DateTime.Now.ToString();


检查此博客
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ]
--NDK
check this blog
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
--NDK


创建按钮和文本框控件:
Create your button and your textbox controls:
<asp:textbox id="TheDateTB" runat="server" xmlns:asp="#unknown"></asp:textbox>
<asp:button id="TheButton" runat="server" text="Press me" onclick="TheButton_Click" xmlns:asp="#unknown" />


然后在Click事件上,在文本框中设置日期:


Then on Click event, set the date in the textbox:

protected void TheButton_Click(object sender, EventArgs e)
{
     TheDateTB.Text = DateTime.Now.ToString("MM/dd/yyyy");
}


这篇关于如何在单击按钮的文本框中插入日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆