2008-11-13 66 views
0

下面的代碼在Page_Load事件中實施,以顯示SaveFileDialog用戶如何在JavaScript中獲得有關SaveFileDialog的用戶響應?

string targetFileName = Request.PhysicalApplicationPath + "Reports\\TempReports\\FolderMasters" + Utility.GetRandomNumber() + ".pdf"; 

FileInfo file = new FileInfo(targetFileName); 
// Clear the content of the response. 
Response.ClearContent(); 

Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); 
Response.AddHeader("Content-Length", file.Length.ToString()); 
Response.ContentType = "application/pdf"; 
Response.TransmitFile(file.FullName); 
Response.End(); 

我怎樣才能得到用戶響應SaveFileDialog,因爲我需要知道用戶反應此對話框?

而且,是有什麼錯的幾行代碼,因爲我有以下異常

「無法因爲代碼優化或本機框上調用堆棧的頂部,以評估表達。」

回答

0

我又來了,因爲我得到了第二個問題的解決方案。

對於Response.End,請調用HttpContext.Current.ApplicationInstance.CompleteRequest方法而不是Response.End以繞過代碼執行到Application_EndRequest事件。

Have look ...

1

你不能得到用戶響應SaveFileDialog所有文件的事件已經被封鎖瀏覽器的JavaScript,因爲它可能是一個非常大的安全孔...

相關問題