当前移动或指望表格的时间 [英] Current Time to move or count on form
本文介绍了当前移动或指望表格的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格,我有一个代码背后的时间。有没有办法让时间像时钟一样移动?例如:如果是下午12:30,我发现它会在一分钟内转到下午12:31而不是刷新页面的时间来改变。
这是我的时间码:
I have a form that I have a code behind for the time. Is there a way to have the time to move like a clock? Ex: If it is 12:30pm I sound see it turn to 12:31pm in a minute not refresh the page for the time to change.
Here is my time code:
this.lblTime.Text = System.DateTime.Now.ToShortTimeString();
I还试过这个:
I also tried this:
this.lblTime.Text = DateTime.Now.ToString("HH:mm:ss ");
and
this.lblTime.Text = Strings.Format("The current time is {0:HH:mm:ss}.", DateTime.Now);
如果没有刷新页面,这些时间没有改变。
No of these the time changed without refreshing the page.
推荐答案
你在谈论一个页面,然后忘记形式这个词 - 它具有特定的含义,需要不同的解决方案。
对于网页,最好的方法是通过JavaScript将其保存到客户端,并且不需要每秒往返服务器...
见这里: http://www.w3schools.com/js/js_timing.asp [ ^ ] - 它提供了几种显示时间的方法!
Of you are talking about a page, then forget the word "form" - it has a specific meaning, and requires a different solution.
For a web page, the best way to do this is via JavaScript so it is kept to the client, and doesn't need a round trip to the server every second...
See here: http://www.w3schools.com/js/js_timing.asp[^] - it presents several ways to display the time!
这篇关于当前移动或指望表格的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文