Click here to Skip to main content
12,395,252 members (68,266 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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

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 22-May-13 21:21pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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:updatepanel id="YourUpdatePanel" runat="server">
 
<triggers><asp:postbacktrigger controlid="YourRepeaterControlID" /></triggers>
 
<contenttemplate>
<!--
Your Repeater Control etc...
 -->
</contenttemplate>
 
</asp:updatepanel>
  Permalink  
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">

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.
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Exactly what i am searching for... Excellent... Thank you.!
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 24 Sep 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100