Ajax开发实例教程.NET页面屏聊系统

豆豆网   技术应用频道   2008年05月08日  【字号: 收藏本文

内容摘要:发现使用Asp.Net Ajax开发包去开发要比原来的asp+ajax简单得多,而且开发完后对浏览器的兼容也大大的提高了。因此懒羊这里就再次献丑,将一些开发心得提供出来与大家一起分享,并提供用户控件供大家下载使用。

  if (Request["url"] != null && Request["begindate"] != null && Request["rndname"] != null)
  
  {
  
  string TempStr = "";
  
  string url = Request["url"].ToString();
  
  string begindate = Request["begindate"].ToString();
  
  string rndname = Request["rndname"].ToString();
  
  string str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["AnchorCallDateBase"]);
  
  OleDbConnection conn = new OleDbConnection(str);
  
  conn.Open(); 
  
  string sql = "select * from chatroom where frompage='"+url+"' and datediff('s','" + begindate + "',dateandtime)>0 order by id desc";
  
  OleDbCommand cmd = new OleDbCommand(sql, conn);
  
  OleDbDataAdapter da = new OleDbDataAdapter(cmd);
  
  DataSet ds = new DataSet();
  
  da.Fill(ds);
  
  if (ds.Tables[0].Rows.Count > 0)
  
  {
  
  for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  
  {
  
  TempStr = "<font color='#ff00000'>" + ds.Tables[0].Rows[i]["nc"].ToString() + ":</font>" + ds.Tables[0].Rows[i]["chatmsg"].ToString() + "<font color='#888888'>[" + DateTime.Parse(ds.Tables[0].Rows[i]["dateandtime"].ToString()).ToShortTimeString() + "]</font><br/>";
  
  this.Label1.Text += TempStr;
  
  }
  
  }
  
  cmd.Dispose();
  
  conn.Close();
  
  conn.Dispose();
  
  Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>document.title='"+rndname+"的聊天记录!'</script>");
  
   }
  
  else
  
  {
  
       this.Label1.Text = "懒羊提示:参数错误!";
  
  Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>document.title='懒羊提示:参数错误!'</script>");
  
   }

来源:it168    作者:懒羊    责编:豆豆技术应用

正在加载评论...