ASP.net中Timer和WebService的使用
示例一
在Global.asax.cs文件中:
protected void Application_Start(Object sender, EventArgs e)
{
System.Timers.Timer timer1 = new System.Timers.Timer();
timer1.Interval = 50000; // 50000 毫秒 = 50秒
timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Elapsed);
timer1.AutoReset = true;
timer1.Enabled = true;
timer1.Start();
}
void timer1_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
// 在这里加上读取数据库的代码就可以实现后台服务定时访问数据库的功能,该功能对于实现文件解
//锁、论坛定时统计等很有用。
}
示例二
通过在网站的Global.asax的Application_Start方法中
加入定时器 定时调用WebService
该WebService的一个方法 负责在后台
向数据库的某个表加入数据
步骤:
1.通过VS 新建一个网站
2.加入Global
相关文档:
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//数据库地址
private string datapatch = "db/global.asa";//数据库地址
///
/// 取得dataset
//
/// 查询语句
///
public DataSet GetDataSet(string Commandtext)
{&nbs ......
法一:调用winrar
using Microsoft.Win32;
using System.Diagnostics;
protected void Button1_Click(object sender, EventArgs e)
{
RAR(@"E:\95413594531\GIS", "tmptest", @"E:\95413594531\");
}
/// < ......
1 ASP.NET 服务器控件GridView使用
本教程不介绍服务器端控件的呈现,事件处理,状态等理论知识,只介绍服务器端控件的使用操作,如果您对服务器控件的知识感兴趣,请参阅《ASP.NET服务器控件高级编程》
阅读本文时最好和 文档 《ASP.NET服务器控件使用之Grid ......
ajax 在目前 web 领域已广泛应用,其真正核心只不过是一个封装好了的 js 库。最五花八门的莫过于 asp.net 的控件,我个人认为 ajax 只是一个轻量级的东西,根本没有必要将它写成服务器组件,如 ajax.net、AjaxControlToolkit 等。所以我一直视这些组件为垃圾。。。
以下说明我为什么不认同 ajax 的相关组件: ......
日期转化一
为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007-01-03 14:33:34 ,要转化为其他格式,要用到DateTime.ToString的方法(String, IFormatProvider),如下所示:
using System;
using System.Globalization;
String format="D";
DateTime date=DataTime,Now;
Response.Write(date.ToS ......