Click here to Skip to main content
11,643,493 members (81,586 online)
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 21: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 485
1 jyo.net 480
2 DamithSL 328
3 Sergey Alexandrovich Kryukov 270
4 CPallini 222
0 DamithSL 541
1 OriginalGriff 495
2 Mika Wendelius 469
3 Sergey Alexandrovich Kryukov 330
4 Afzaal Ahmad Zeeshan 324


Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2015
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