《ASP.NET1200例》C#在网页上编写动态时钟
包含Timer类的命名空间有3个
Timer Class (System.Threading)
Timer Class (System.Windows.Forms) 一般用于窗体程序
Timer Class (System.Timers) 一般用于控制台程序
using System; using System.Timers;
class Program
{
public static void Main()
{
Timer t = new System.Timers.Timer();
t.Interval = ;
//t.AutoReset = false; //每到指定时间Elapsed事件是触发一次(false),还是一直触发(true)
t.Enabled = true; //是否触发Elapsed事件
t.Elapsed += new ElapsedEventHandler(t_Elapsed); Console.WriteLine("Press the Enter key to exit the program.");
//从标准输入流读取下一行
Console.ReadLine();
// Keep the timer alive until the end of Main.
GC.KeepAlive(t);
} static void t_Elapsed(object sender, ElapsedEventArgs e)
{
Console.WriteLine("hello world!!");
}
}
Timer Class(using System.Web.UI)一般用于web程序
using System.Web.UI;
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
Timer1.Interval = ;
Timer1.Enabled = true;
Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick); } void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
此时前端代码.aspx
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> <div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Timer ID="Timer1"
runat="server">
</asp:Timer> </div>
</form>
</body>
《ASP.NET1200例》C#在网页上编写动态时钟的更多相关文章
- canvas :原生javascript编写动态时钟
canvas :原生javascript编写动态时钟 此时针是以画布的中心为圆心: g.translate(width/2,width/2); 此函数是将画布的原点移到(width/2,wid ...
- Flash文件在asp页面无法播放,网页上面的Flash文件在火狐浏览器不播放
第一个问题:Flash文件放到asp页面以后无法播放. 解决方法:用浏览器打开页面->F12,选择Network,如下图: 然后刷新页面,如下图: 点击左侧状态是404的文件,如图: 可以发现F ...
- 《ASP.NET1200例》在DataList里编辑和删除数据
学习内容:如何创建一个支持编辑和删除数据的DataList.增加编辑和删除功能需要在DataList的ItemTemplate和EditItemTemplate里增加合适的控件,创建对应的事件处理,读 ...
- 《ASP.NET1200例》ListView控件之修改,删除与添加
aspx <body> <form id="form1" runat="server"> <div> <asp:Lis ...
- 《ASP.NET1200例》ListView 控件与DataPager控件的结合<二>
ASP.NET使用ListView数据绑定控件和DataPager实现数据分页显示 为什么使用ListView+DataPager的方式实现分页显示? .net提供的诸多数据绑定控件,每一种都有它自己 ...
- 《ASP.NET1200例》解决母版页报错“内容控件必须是内容页中的顶级控件,或是引用母版页的嵌套母版页。”
VS2005下,添加了母版页这个控件,我们可以讲N个页面中共同的部分放在母版页来实现,并让WEB窗体集成自我们的母版页,就可以让我们的站点具有统一的风格了.在VS2005SP1之前的版本中,我们只能创 ...
- 《ASP.NET1200例》ListView 控件与DataPager控件的结合<一>
分页 在前一部分开始时介绍的原 HTML 设计中内含分页和排序,所以根据规范完整实现该网格的任务尚未完成.我们先分页,然后再排序. ListView 控件中的分页通过引入另一个新控件 Data ...
- 《ASP.NET1200例》<asp:DataList>分页显示图片
aspx页面代码 <asp:DataList ID="dlPhoto" runat="server" Height="137px" W ...
- 《ASP.NET1200例》实现投票的用户控件
用户控件ascx <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="24 ...
随机推荐
- nutch中bin/crawl和bin/nutch crawl的用法(转)
针对上一篇文章中出现的问题:Command crawl is deprecated, please use bin/crawl instead错误信息,今天在官网上查阅了一下,进行了总结. 官网lin ...
- Android简单介绍
1)Android定义: 2)版本号变迁 3)开发类型 4)Android五大组件 5)Android五大布局
- C++ - 派生类强制转换为基类
派生类强制转换为基类 本文地址: http://blog.csdn.net/caroline_wendy/article/details/24268821 在多态的使用时, 派生类的指针或引用能够转换 ...
- python list插入、拼接
1可以使用"+"号完成操作 输出为: [1, 2, 3, 8, 'google', 'com'] 2.使用extend方法 . 输入相同 3使用切片 输出相同 PS:len(l1) ...
- Lintcode---验证二叉查找树
给定一个二叉树,判断它是否是合法的二叉查找树(BST) 一棵BST定义为: 节点的左子树中的值要严格小于该节点的值. 节点的右子树中的值要严格大于该节点的值. 左右子树也必须是二叉查找树. 一个节点的 ...
- spine findBone
spBone* bone=skeletonAnimationNode->findBone("boneName"); CCPoint boneWorldPos=ccp(bone ...
- unity的自带特性
2016/9/24补充: unity官方有一篇文章对菜单扩展讲的不错 https://unity3d.com/cn/learn/tutorials/topics/interface-essential ...
- 李洪强总结KVC用法
- Jquery js框架使用
jquery 众所周知 ,强大的 js框架 自己使用的一些笔记 //1.json格式定义方法 var product_obj={ check_init:function(){ ...
- maven仓库镜像配置
<!-- 阿里云仓库 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirror ...