vs2005+ajax要实现以前的效果实在是太简单啦.主要大家熟悉了AJAX Extensions几个控件.做起来就是跟以前的效果一样
大家见code吧
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TTimer.aspx.cs" Inherits="TTimer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick">
</asp:Timer>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class TTimer : System.Web.UI.Page
{
private DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
binddata();
}
private void binddata()
{
string sql = "select Class_ID,Class_Name,Class_Pid from TC_User order by Class_ID ";
string strconn = "Data Source=SEE-CLN-059\\PMSERVER;Initial Catalog=test;uid=sa;pwd=;";
Conn conn = new Conn(strconn);
ds = conn.GetSet(sql);
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
binddata();
}
}
当然遇到异常的情况请自己写异常错误显示吧...