Click here to Skip to main content
Rate this: bad
good
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 22:21pm

1 solution

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 at 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 at 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.

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

  Print Answers RSS
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2014
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