我在一个框架页面中的一个页面上有一个打印按纽,点击可以打印出当前页面(框架中该按纽所在页面),下面是段代码。但运行后为什么会打印出的是另外一个页面呢?在线等待
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=OUTPUTWORD.doc");
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/ms-word ";
Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
this.Page.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=OUTPUTWORD.doc");
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/ms-word ";
Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
this.Page.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
<script language="javascript">
function printdoc()
{
window.print();
}
</script>
请路过的帮我看看,非常感谢!