当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net Timer的使用方法

asp.net Timer的使用方法

2018年04月20日  | 移动技术网IT编程  | 我要评论

longzu,junqingguanchashi,外置蓝光光驱

页面代码: 
复制代码 代码如下:

<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %>
<%@ register assembly="ajaxcontroltoolkit" namespace="ajaxcontroltoolkit" tagprefix="cc1" %>
<!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="head1" runat="server">
<title>untitled page</title>
<style type="text/css">
#updatepanel3 {
border-right: gray 1px solid; border-top: gray 1px solid;
border-left: gray 1px solid; border-bottom: gray 1px solid;
width:200px; height:200px; position: relative;
float: left; margin-left: 10px; margin-top: 10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="scriptmanager1" runat="server" />
<asp:updatepanel id="updatepanel3" runat="server">
<contenttemplate>
<asp:timer id="timer1" runat="server" interval="1000" ontick="timer1_tick">
</asp:timer>
<asp:label id="label3" runat="server" text="label"></asp:label><br />
</contenttemplate>
</asp:updatepanel>
<asp:label id="label4" runat="server" text="label"></asp:label>
</form>
</body>
</html>

cs文件代码:
复制代码 代码如下:

using system;
using system.data;
using system.configuration;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.threading;
public partial class _default : system.web.ui.page
{
protected void page_load(object sender, eventargs e)
{
label4.text = "初始化时间:" + datetime.now.tostring();
timer1.interval = 1000;
}
protected void timer1_tick(object sender, eventargs e)
{
label3.text = "刷新时间:" + datetime.now.tostring();
}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网