using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class print2 : System.Web.UI.Page { LYS.UserData1 myud = new LYS.UserData1(); protected void Page_Load(object sender, EventArgs e) { //用Session保存当前页 //if (Session["Username"] == null) //{ Response.Redirect("LoginNew.aspx"); } string myURL = myud.GetAddressUrl().ToString(); if (myURL.LastIndexOf("ID") < 0) { Response.Write(""); Response.End(); } int ID = Convert.ToInt16(Request.QueryString["ID"].ToString()); if (!IsPostBack) { ZJ.Text = Convert.ToDateTime(myud.GetFieldValue(5, ID, "TKJL").ToString()).ToLongDateString(); ZJ1.Text = ZJ.Text; DDXM.Text = myud.GetFieldValue(4, ID, "TKJL").ToString(); DD.Text = myud.GetFieldValue(9, ID, "TKJL").ToString(); // DDXM1.Text = myud.GetFieldValue(4, ID, "TKJL").ToString(); // DDXM2.Text = myud.GetFieldValue(4, ID, "TKJL").ToString(); // DDXM4.Text = myud.GetFieldValue(4, ID, "TKJL").ToString(); JSXM.Text = myud.GetFieldValue(1, ID, "TKJL").ToString(); XB.Text = myud.GetFieldValue(2, ID, "TKJL").ToString(); KM.Text = myud.GetFieldValue(3, ID, "TKJL").ToString(); BJ.Text = myud.GetFieldValue(6, ID, "TKJL").ToString(); XQ.Text = myud.GetFieldValue(7, ID, "TKJL").ToString(); JC.Text = myud.GetFieldValue(8, ID, "TKJL").ToString(); PF.Text = myud.GetFieldValue(28, ID, "TKJL").ToString(); PJ.Text = myud.GetFieldValue(26, ID, "TKJL").ToString(); } } protected void Button3_Click(object sender, EventArgs e) { HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Charset = "gb2312"; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); HttpContext.Current.Response.ContentType = "application/ms-word"; HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=fileDown.doc"); //关闭控件的视图状态 ,如果仍然为true,RenderControl将启用页的跟踪功能,存储与控件有关的跟踪信息 this.EnableViewState = false; //将要下载的页面输出到HtmlWriter System.IO.StringWriter writer = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer); this.RenderControl(htmlWriter); //提取要输出的内容 string pageHtml = writer.ToString(); int startIndex = pageHtml.IndexOf("