注册 登录
编程论坛 ASP.NET技术论坛

关于将Asp.Net页面输出到EXCEL里去的问题

bobingpzm 发布于 2008-08-12 17:14, 1075 次点击
protected void Button3_Click(object sender, EventArgs e)
        {
           Response.Clear();
         Response.Buffer= true;
         Response.Charset="utf-8";     
           Response.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");  
           Response.ContentEncoding = System.Text.Encoding.Default;     
           Response.ContentType = "application/ms-excel";
         this.EnableViewState = false;                         
            oStringWriter = new ();
        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
           this.RenderControl(oHtmlTextWriter);
         Response.Write(oStringWriter.ToString());
         Response.End();
        }
调试显示RegisterForEventValidation can only be called during Render();的错误!
不知道为什么!请高手指教。
2 回复
#2
雪雨星风2008-08-15 10:01
#3
chenlong2008-10-27 14:56
要写一个空的VerifyRenderingInServerForm方法(必须写),以确认在运行时为指定的 服务器控件呈现HtmlForm 控件。
public override void VerifyRenderingInServerForm(Control control)
{
 // Confirms that an HtmlForm control is rendered for
}
1