如何实现打印网页panel中的内容

libingzhg 2004-06-11 04:53:07
如何实现打印网页panel中的内容,此panel中是几个datagrid.查询执行后生成数据表格。我需要点击页面上的打印按钮打印查询出的内容。只打印panel中的
...全文
59 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaomaoy 2004-08-19
  • 打赏
  • 举报
回复
//将HTTP头添加到输出流
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc");

//指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true;

System.IO.StringWriter tw= new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.Panel1.Visible =true;

//将服务器控件中的内容输出到ystem.Web.UI.HtmlTextWriter对象中
this.Panel1.RenderControl(hw);

HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧