2010-06-24 53 views
0

這段代碼在control.ascx中,控件放在ModalPopup.aspx頁面中。在模態彈出窗口中響應一個xml文件

首先嚐試使用response.end() - 此代碼拋出異常。 ai試過coment這一行後,但沒有任何事情發生。

瀏覽器IE8是

try 
    { 
     //export 
     StringBuilder sb = ExportToExcelXml(); 
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); 
     byte[] byteText = encoding.GetBytes(sb.ToString()); 

     Response.Clear(); 
     Response.Charset = "utf-8"; 
     Response.ContentType = "text/xls"; 
     Response.AddHeader("content-disposition", "attachment; filename=export.xls"); 
     Response.BinaryWrite(byteText); 
     //Response.End();   
    } 
    catch (Exception ex) 
    { 
+0

我忘了說,這個控件放在aspx頁面時非模態彈出 - 工作正常 – Artiom 2010-06-24 15:49:46

+0

我也面臨同樣的問題,下載莫塔爾彈出窗口不工作。您是否找到了解決方案/解決方法? – 2010-11-23 11:52:36

回答

0

一旦反應已經開始,你不能清除它,改變它的內容類型。對於.ascx文件,您位於可能已經開始填寫響應的.aspx文件中。你可以將它移動到.ashx(通用處理程序)嗎?

+0

我現在沒有關於.ashx 我將學習。 – Artiom 2010-06-24 15:21:35