2017-11-09 18 views
0

Excelのダウンロード中にイメージローダーを作成しようとしていました。これは私の現在のコードです。 aspxページで ファイルのダウンロードが完了してもPostbackTriggerが凍っているUpdatePanel

function ShowProgress() { 
    document.getElementById('<% Response.Write(prgLoadingStatus.ClientID); %>').style.display = "inline"; 
} 

Javascriptを

<asp:UpdatePanel ID="upAlignBuyer" runat="server" UpdateMode="Conditional" EnableViewState="true" > 
<ContentTemplate> 
    <asp:Button ID="Button2" Text="Download BWS" CssClass="app_button" 
     Font-Bold="true" value="DownloadExcel" OnClick="Download_Click" OnClientClick="ShowProgress();" 
     runat="server" Height="23px" Width="120px"></asp:Button> 
    <asp:UpdateProgress ID="prgLoadingStatus" runat="server" DynamicLayout="true" AssociatedUpdatePanelID="upAlignBuyer" > 
     <ProgressTemplate> 
      <div id="overlay"> 
       <div id="modalprogress"> 
        <div id="theprogress"> 
         <asp:Image ID="imgWaitIcon" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/App_Themes/Images/progress.gif" /> 
          Please wait... 
        </div> 
       </div> 
      </div> 
     </ProgressTemplate> 
    </asp:UpdateProgress> 
</ContentTemplate> 
<Triggers> 
    <asp:PostBackTrigger ControlID="Button2" /> 
</Triggers> 
</asp:UpdatePanel> 

だからこれに伴う問題は、適切に画像の負荷をロードすると、ファイルが正しくダウンロードされているが、それは、ファイルを取得した後も、ローディング画像を表示し続けますダウンロード。 どんな助力も素晴らしいでしょう。

答えて

0

これは良い解決策ではないかもしれませんが、私はこの方向に向かっています。 ファイルがダウンロードされたときのように、ページの状態が「完了」に設定されることはありません。常に「インタラクティブ」で終わっていました。

document.onreadystatechange = function() { 
     if (document.readyState === "interactive") { 
       HidePrograss(); 
     } 
} 

function ShowProgress() { 
    document.getElementById('<% Response.Write(prgLoadingStatus.ClientID); 
      %>').style.display = "inline"; 
} 

function HidePrograss() { 
     document.getElementById('<% Response.Write(prgLoadingStatus.ClientID); 
      %>').style.display = "none"; 
} 

このようにupdateprogressは表示されず、ファイルのダウンロード時には表示されません。

誰かがもっと良い解決策を持っている場合は、私に知らせてください。

関連する問題