0

I have a gridView to show up document (.PDF) list and a LinkButton to download/read document.

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);
            }
        }

All the code above are worked perfect.

Next I make some improvements: add a loadding screen while codes are executed on server

<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();
}  

After improvement, when clicking on LinkButton lblDocTitle the loadding screen show up and still loading loading loading... and loading forever.

I don't know why and how to fix that bug hope some help ?

Thanks !

Shinichi
  • 475
  • 4
  • 7
  • 25

1 Answers1

0

OK I fix that error. Just use other ASPX page to handle download file. UpdatePanel can not response other output except HTML :D

Shinichi
  • 475
  • 4
  • 7
  • 25