一些小的网站经验

来源:互联网 发布:2016欧洲杯数据统计 编辑:程序博客网 时间:2024/05/17 06:24
  1. 1.javascript谈屏 
  2. public static void JsAlert(string message, string url, string retype)
  3.     {
  4.         string URL;
  5.         if (retype == null)
  6.         {
  7.             URL = "window.location.href='" + url + "';";
  8.         }
  9.         else if (retype == "parent")
  10.         {
  11.             URL = "parent.window.location.href='" + url + "';";
  12.         }
  13.         else if (retype == "opener")
  14.         {
  15.             URL = "opener.window.location.href='" + url + "';";
  16.         }
  17.         else
  18.         {
  19.             URL = "window.location.href='" + url + "';";
  20.         }
  21.         HttpContext.Current.Response.Write("<script>");
  22.         HttpContext.Current.Response.Write("alert('" + message + "');");
  23.         HttpContext.Current.Response.Write(URL);
  24.         HttpContext.Current.Response.Write("</script>");
  25.     }
  26. //rep绑定
  27.     public void test()
  28.     {
  29.         DataSet ds = Database.ExecuteDataSet(sql);
  30.         for (int i = 0; i < Repeater1.Items.Count; i++)
  31.         {
  32.             Label lab = (Label)Repeater1.Items[i].FindControl("Label1");
  33.             CheckBox cb = (CheckBox)Repeater1.Items[i].FindControl("CheckBox1");
  34.             foreach (DataRow dr in ds.Tables[0].Rows)
  35.             {
  36.                 if (lab.Text.Equals(dr["OperationName"].ToString()))
  37.                 {
  38.                     cb.Checked = truebreak;
  39.                 }
  40.                 else
  41.                 {
  42.                     cb.Checked = false;
  43.                 }
  44.             }
  45.         }
  46.     }
  47. //日期是否过期
  48.     public void B()
  49.     {
  50.         DataTable dtBuyer = new DataTable(); 
  51.         dtBuyer.Columns.Add("BId"typeof(int));
  52.         dtBuyer.Columns.Add("BuyerName"typeof(String));
  53.         dtBuyer.Columns.Add("Information"typeof(System.String));
  54.         dtBuyer.Columns.Add("Title"typeof(String)); 
  55.         dtBuyer.Columns.Add("leaveTime"typeof(String)); 
  56.         foreach (DataRow dr in dsBuyer.Tables[0].Rows)
  57.         {
  58.             DateTime dtBuyTime = Convert.ToDateTime(dr["BuyTime"]); 
  59.             int duration = Convert.ToInt32(dr["Duration"]); 
  60.             TimeSpan leave = dtBuyTime.AddDays(duration).Subtract(DateTime.Now);
  61.             DataRow drData = dtBuyer.NewRow(); 
  62.             drData["BId"] = dr["BId"].ToString(); 
  63.             drData["BuyerName"] = dr["BuyerName"].ToString();
  64.             drData["Information"] = dr["Information"].ToString(); 
  65.             drData["Title"] = dr["Title"].ToString(); 
  66.             if (leave.Seconds <= 0)
  67.             {
  68.                 drData["leaveTime"] = "已过期"
  69.             }
  70.             else
  71.             {
  72.                 drData["leaveTime"] = leave.Days + "天"
  73.             }
  74.             dtBuyer.Rows.Add(drData);
  75.         }
  76.         DataView dv = new DataView(dtBuyer);
  77.         gvBuyer.DataSource = dv; gvBuyer.DataBind();
  78.     }
原创粉丝点击