2014-07-24 69 views
0

我使用Response.Write單擊按鈕創建採購訂單PDF。response.write屏幕未更新後

Response.ContentType = "pdf/application"; 
    Response.AddHeader("content-disposition", "attachment;filename=PurchaseOrder.pdf"); 
    Response.OutputStream.Write(ms.ToArray(), 0, ms.ToArray().Length); 

在那之後,我嘗試更新屏幕顯示,訂單已提出:

labelReqPOStatus.Text = "PO Raised"; 

屏幕不會得到更新。我怎樣才能做到這一點?

+0

ms是一個內存流嗎?如果是這樣,你在調用ToArray()之前將它的位置設置爲0?也Response.End()可能有幫助 – Victor

+1

你簡單不能那樣做!同樣的答案http://stackoverflow.com/questions/14760154/response-transmitfile-nothing-happening/14760372#14760372 – Aristos

回答

1

正如Aristos所說 - 這是不可能的。你可以做的是

1)本次更新的部分更新頁面第一

labelReqPOStatus.Text = "PO Raised"; 

2)添加JavaScript代碼來開始實際PDF下載(假設你有「Handler1.ashx」,將像你提到的那樣提供文件)

ClientScript.RegisterClientScriptBlock(GetType(), "Download", "window.open('Handler1.ashx')", true); 
+0

我喜歡這個解決方案。 –