0
我有一個gridView來顯示文檔(.PDF)列表和一個LinkButton來下載/讀取文檔。推送文件到客戶端使用後不工作UpdatePanelAinimationExtender
的LinkButton:
<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();
}
改進後,在LinkButton的lblDocTitle
點擊時loadding屏幕顯示並仍然加載加載...並永久加載。
我不知道爲什麼以及如何解決該錯誤希望得到一些幫助?
謝謝!