我需要知道如何编码以在标签或文本框中显示按钮单击时间(系统时间)。

问题描述:

你好,任何人都可以帮助我实现上述目标。



实际上我正在开发一个包含按钮和标签的Web应用程序我想要的是当我点击按钮时,它应该显示发生点击的时间。



例如:



如果我点击标签中的button1它应显示为



最后点击发生在3-7-2014 5:13 PM





如何在Textview中显示








提前致谢..

Hi can any one help me to achieve the above mentioned thing.

Actually i'm developing an web application which contains button and an label what i want is when ever i click on the button it should display the time of the click that takes place.

For Eg:

if i click the button1 in label it should display as

Last Click takes place at 3-7-2014 5:13 PM


How to display in Textview




Thanks in advance..

试试这段代码

Try this code
protected void Button1_Click(object sender, EventArgs e)
    {
      Label1.Text=DateTime.Now.ToString();
    }


试试这个



Button_Click(...)

{

txtbox.Text =最后点击发生在+ DateTime.Now.Tostring();

}
try this

Button_Click(...)
{
txtbox.Text="Last Click takes place at "+DateTime.Now.Tostring();
}


您好



以下代码解决了我的问题。





TextView tv =(TextView)findViewById(R.id.textView1);

Date cal =(Date)Calendar.getInstance()。getTime();

date = cal.toLocaleString();

tv.setText(date.toString());
Hi

The below code solved my problem.


TextView tv = (TextView) findViewById(R.id.textView1);
Date cal = (Date) Calendar.getInstance().getTime();
date = cal.toLocaleString();
tv.setText(date.toString());