0

我有一個gridView來顯示文檔(.PDF)列表和一個LinkBut​​ton來下載/讀取文檔。推送文件到客戶端使用後不工作UpdatePanelAinimationExtender

的LinkBut​​ton:

<ItemTemplate> 
    <asp:LinkButton ID="lbDocTitle" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' Text='<%# DataBinder.Eval(Container.DataItem, "Content") %>' OnClick="lbDocTitle_Click"></asp:LinkButton> 
</ItemTemplate> 

lbDocTitle_click

protected void lbDocTitle_Click(object sender, EventArgs e) 
     { 
      LinkButton btn = (sender as LinkButton); 

      int docID = Convert.ToInt32(btn.CommandArgument); 
      //get fileName from docID here... 

      ReadPdfFile(fileName); 

     } 


private void ReadPdfFile(string fName) 
     { 

      WebClient client = new WebClient(); 
      Byte[] buffer = client.DownloadData(fName); 

      if (buffer != null) 
      { 
       Response.ContentType = "application/pdf"; 
       Response.AddHeader("content-length", buffer.Length.ToString()); 
       Response.BinaryWrite(buffer); 
      } 
     } 

所有的代碼上面工作完美。

接下來,我做了一些改進:添加loadding屏幕,而代碼在服務器執行

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 

<asp:UpdatePanel ID="updatePanel" runat="server"> 
<ContentTemplate> 
    <asp:GridView ...> <!-- move gridview here --> 
</ContentTemplate> 
</UpdatePanel> 


<asp:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server" TargetControlID="updatePanel"> 
       <Animations> 
        <OnUpdating> 
         <Parallel duration="0"> 
          <ScriptAction Script="onUpdating();" /> 
         </Parallel> 
        </OnUpdating> 
        <OnUpdated> 
         <Parallel duration="0"> 
          <ScriptAction Script="onUpdated();" /> 
         </Parallel> 
        </OnUpdated> 
       </Animations> 
      </asp:UpdatePanelAnimationExtender> 

JavScript:

function onUpdating() { 
    $('#loadingBox-holder').show(); 
    $('#loadingBox').show(); 
} 

function onUpdated(x) { 
    $('#loadingBox-holder').hide(); 
    $('#loadingBox').hide(); 
} 

改進後,在LinkBut​​ton的lblDocTitle點擊時loadding屏幕顯示並仍然加載加載...並永久加載。

我不知道爲什麼以及如何解決該錯誤希望得到一些幫助?

謝謝!

回答

0

好的我修復了這個錯誤。只需使用其他ASPX頁面來處理下載文件。 UpdatePanel無法響應HTML以外的其他輸出:D