一些小的网站经验
来源:互联网 发布:2016欧洲杯数据统计 编辑:程序博客网 时间:2024/05/17 06:24
- 1.javascript谈屏
- public static void JsAlert(string message, string url, string retype)
- {
- string URL;
- if (retype == null)
- {
- URL = "window.location.href='" + url + "';";
- }
- else if (retype == "parent")
- {
- URL = "parent.window.location.href='" + url + "';";
- }
- else if (retype == "opener")
- {
- URL = "opener.window.location.href='" + url + "';";
- }
- else
- {
- URL = "window.location.href='" + url + "';";
- }
- HttpContext.Current.Response.Write("<script>");
- HttpContext.Current.Response.Write("alert('" + message + "');");
- HttpContext.Current.Response.Write(URL);
- HttpContext.Current.Response.Write("</script>");
- }
- public void test()
- {
- DataSet ds = Database.ExecuteDataSet(sql);
- for (int i = 0; i < Repeater1.Items.Count; i++)
- {
- Label lab = (Label)Repeater1.Items[i].FindControl("Label1");
- CheckBox cb = (CheckBox)Repeater1.Items[i].FindControl("CheckBox1");
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- if (lab.Text.Equals(dr["OperationName"].ToString()))
- {
- cb.Checked = true; break;
- }
- else
- {
- cb.Checked = false;
- }
- }
- }
- }
- public void B()
- {
- DataTable dtBuyer = new DataTable();
- dtBuyer.Columns.Add("BId", typeof(int));
- dtBuyer.Columns.Add("BuyerName", typeof(String));
- dtBuyer.Columns.Add("Information", typeof(System.String));
- dtBuyer.Columns.Add("Title", typeof(String));
- dtBuyer.Columns.Add("leaveTime", typeof(String));
- foreach (DataRow dr in dsBuyer.Tables[0].Rows)
- {
- DateTime dtBuyTime = Convert.ToDateTime(dr["BuyTime"]);
- int duration = Convert.ToInt32(dr["Duration"]);
- TimeSpan leave = dtBuyTime.AddDays(duration).Subtract(DateTime.Now);
- DataRow drData = dtBuyer.NewRow();
- drData["BId"] = dr["BId"].ToString();
- drData["BuyerName"] = dr["BuyerName"].ToString();
- drData["Information"] = dr["Information"].ToString();
- drData["Title"] = dr["Title"].ToString();
- if (leave.Seconds <= 0)
- {
- drData["leaveTime"] = "已过期";
- }
- else
- {
- drData["leaveTime"] = leave.Days + "天";
- }
- dtBuyer.Rows.Add(drData);
- }
- DataView dv = new DataView(dtBuyer);
- gvBuyer.DataSource = dv; gvBuyer.DataBind();
- }