public void DownContent(int ID) { Lb_result.Text = ""; EnterpriseOpration.Notification filePub = new EnterpriseOpration.Notification(); filePub.ID = ID; DataTable dt = filePub.getOriginTableByID(); if (dt.Rows[0]["thefile"] != System.DBNull.Value) { byte[] thefile = (byte[])dt.Rows[0]["thefile"]; string fileName = dt.Rows[0]["name"].ToString() + "." + dt.Rows[0]["filetype"].ToString(); fileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); this.Response.ContentType = dt.Rows[0]["ContentType"].ToString(); this.Response.AppendHeader("Content-Disposition", "attachment;filename = " + fileName); this.Response.OutputStream.Write(thefile, 0, thefile.Length); this.Response.OutputStream.Close(); HttpContext.Current.Response.End(); } else { Lb_result.Text = "本记录没有文件!"; } }
protected void Page_Load(object sender, EventArgs e) { ModuleKey = "010101"; ModuleName = "日常办公-通知通告"; Response.Cache.SetExpires(DateTime.Now); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(true); if (!IsPostBack) { string operate = Request["code"].ToString(); HF_Operate.Value = operate; if (operate != "add") { string id = Request["id"].ToString(); HF_ID.Value = id; EnterpriseOpration.Notification note = new EnterpriseOpration.Notification(); note.ID = Int32.Parse(id); DataTable table = note.getOriginTableByID(); TB_name.Value = table.Rows[0]["name"].ToString(); TA_Memo.Value = table.Rows[0]["memo"].ToString(); this.Title = "修改通知通告"; } } }
protected void Lbtn_newsContent_Click(object sender, EventArgs e) { Lb_result.Text = ""; EnterpriseOpration.Notification filePub = new EnterpriseOpration.Notification(); filePub.ID = Convert.ToInt32(Request["__EVENTARGUMENT"]); DataTable dt = filePub.getOriginTableByID(); if (dt.Rows[0]["thefile"] != System.DBNull.Value) { byte[] thefile = (byte[])dt.Rows[0]["thefile"]; string fileName = dt.Rows[0]["name"].ToString() + "." + dt.Rows[0]["filetype"].ToString(); fileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); this.Response.ContentType = dt.Rows[0]["ContentType"].ToString(); this.Response.AppendHeader("Content-Disposition", "attachment;filename = " + fileName); this.Response.OutputStream.Write(thefile, 0, thefile.Length); this.Response.OutputStream.Close(); HttpContext.Current.Response.End(); } else { Lb_result.Text = "本记录没有文件!"; } }