2013-11-21 121 views
0

我有一個Aspx頁面。 開啓按鈕單擊我正在從服務器下載文件。文件下載後文件準備不工作

用於下載文件的服務器端代碼。 aspx頁面上

byte[] data = GetBytes(); 
    //Sets the Content Type and FileName 
    HttpContext.Current.Response.ContentType = "plan/text"; 
    HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "Error.txt")); 

    //Writes the Content in HttpResponse 
    //to enable downloading the file. 
    HttpContext.Current.Response.Clear(); 
    HttpContext.Current.Response.BinaryWrite(data); 
    HttpContext.Current.Response.End(); 

JavaScript代碼。

$(document).ready(function() { 
alert(1); 
}); 

該警報是越來越顯示在第一頁的負荷。 但它在文件下載回發後不顯示警報。 在此先感謝。

+0

最可能的是,你可能不會有一個回 –

+0

@SubinJacob是文件下載頁面時要求越來越取消。他們的任何方式,我可以在downlaod完成後觸發一個javascript方法嗎? – sudhAnsu63

回答

0

這是因爲Partial Postback。您需要使用PageRequestManager來設置請求處理程序。然後請求處理程序將在部分回發中執行。

See This answer

See This answer

+0

我沒有使用任何UpdatePanel或ScriptManager。 – sudhAnsu63

+0

嘗試在代碼後面移除respose.end。讓我們看看它是否有效。 –

+0

刪除Response.End()後無效果; – sudhAnsu63