簡體   English   中英

從服務器下載文件后,無法隱藏Gif圖像。(C#和javascript)

[英]Unable to hide a Gif image after file download from server.(C# and javascript)

我有一個棘手的情況:

有只帶有按鈕的UI。 在按鈕上單擊,我在服務器中處理PowerPoint文檔(我向幻燈片中添加了一些相關內容),然后將其下載到客戶端系統。

現在,當用戶單擊下載按鈕時,我會顯示一個小的動畫gif,上面寫着“正在處理”,但是當PowerPoint文件下載到客戶端系統時,我無法隱藏或禁用“正在處理圖像”。

這是服務器端代碼:

HttpContext.Current.Response.ContentType = "APPLICATION /OCTET-STREAM";

String Header = "Attachment; Filename=" + FileName;
HttpContext.Current.Response.AppendHeader("Content-Disposition", Header);
//for the server

//for normal 
System.IO.FileInfo Dfile = new System.IO.FileInfo(PPTPath);

HttpContext.Current.Response.WriteFile(Dfile.FullName);

這是客戶端代碼:

ShowProcessMessage = function(PanelName)
{
    document.getElementById(PanelName).hidden = "";
    document.getElementById("Image1").style.visibility = "visible";

    return true; //Returns the control to the Server click event
}

誰能提出一些實施建議?

可能的解決方案是執行客戶端Ajax調用。 使用beforeSend來顯示微調器,並使用完成以隱藏微調器(在失敗成功時完全觸發)

$.ajax({
        url: linktoPdf
                , beforeSend: function (xhr) { $('#idOfSpinner').addClass("showSpinner"); }
                , complete: function () { $('#idOfSpinner').removeClass("showSpinner"); }
                , success: function (response)  { /*your code here */ }
            , error: function () { /*your code here */ }
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM