Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a repeater control which is inside Update Pannel this update pannel contains Asynchronous postBack triggers.this repeater shows the files from certain folder.i have item commends for download and delete files.in the update pannel control i called the asynchronous trigger for delete files because i wanted to update repeated withot postback its working fine.but when i tried to download the file its not working the fallowing is the code its working for when i place a button and call the same method

C#
public void DownloadFile(string filePath)
        {
            if (File.Exists(HttpContext.Current.Server.MapPath(filePath)))

            {

              string fileName = Path.GetFileName(filePath);
                    Response.ClearHeaders();
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename="+fileName);
                    Response.TransmitFile(@"~\Uploads\"+fileName);
                    //Response.End();
                    HttpContext.Current.ApplicationInstance.CompleteRequest();


}


The above code is working from the button which is outside the repeater but it is not working for the linkbutton which is in repeater
Posted

Yes. It will not work inside updatepanel. You will have to add a postback trigger inside updatepanel. specify your repeater's ID controlID. For example something like this:

ASP.NET
<asp:updatepanel id="YourUpdatePanel" runat="server">
 
<triggers><asp:postbacktrigger controlid="YourRepeaterControlID" /></triggers>
 
<contenttemplate>
<!--
Your Repeater Control etc...
 -->
</contenttemplate>
 
</asp:updatepanel>
 
Share this answer
 
v2
Comments
krishna_goluguri 23-May-13 3:37am    
I used the same like above but instead of <asp:postbacktrigger i used asp:AsyncPostBackTrigger
my code is like below
<asp:UpdatePanel runat="server" ID="upFiles" UpdateMode="Conditional">
<contenttemplate>
Repeater control

<Triggers>
<asp:AsyncPostBackTrigger ControlID="rptUploadedFiles" />
<asp:AsyncPostBackTrigger ControlID="btnRefreshFileList" />


</Triggers>
Zafar Sultan 23-May-13 5:43am    
Replace <asp:AsyncPostBackTrigger ControlID="rptUploadedFiles" /> with
<asp:PostBackTrigger ControlID="rptUploadedFiles" />

It's the only way you can make it work.
Member 14054506 6-Jun-19 2:31am    
its worked, thnks a lot
Cipherc 12-Dec-15 16:35pm    
@Zafar Very beautiful! I searched for hours before landing on to your solution. Jazakallah
Zafar Sultan 14-Dec-15 2:34am    
Wa-Iyak
Exactly what i am searching for... Excellent... Thank you.!
 
Share this answer
 
Comments
CHill60 25-Sep-15 6:25am    
If you want to leave a comment to a poster then use the "Have a Question or Comment?" link next to the post. Don't use solutions to leave messages - the OP might get informed but the person you are trying to thank will not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900