download file in Ajax Panel

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 16 Apr 2015 Link to this post

    I put an Ajax panel on my page but now downloads do not work, I know is cause of the response.write stream.  I s there a way to get around this in the code behind of the itemCommand.  The downloads are in a sub grid of my main grid so I cannot take it out of the ajax panel.


                                   <telerik:GridTableView DataKeyNames="intUploadId" Name="SubGrid" Width="50%" TableLayout="Fixed" Font-Size="10" AutoGenerateColumns="False" SkinID="Web20">
                                               <telerik:GridRelationFields DetailKeyField="intWarrantyNumId" MasterKeyField="intWarrantyNumId" />
                                           <HeaderStyle Font-Bold="true" HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center"  />
                                           <AlternatingItemStyle HorizontalAlign="Center" />
                                                <telerik:GridTemplateColumn HeaderText="File">
                                                        <asp:LinkButton ID="lnkDelete" runat="server" CommandArgument='<%# Bind("intUploadId")%>' CommandName="DeleteDoc" OnClientClick="return confirm('Are you sure you want to delete this attachment');">
                                                            <asp:Image ID="imgDelete" runat="server" ImageUrl="~/Images/Delete Circle Small.png" BorderStyle="None" />
                                                <telerik:GridTemplateColumn HeaderText="File">
                                                        <asp:LinkButton ID="lnkFile" runat="server" Text='<%# Bind("strLocation")%>' CommandArgument='<%# Bind("strLocation")%>' CommandName="Download"></asp:LinkButton>
     If (e.CommandName = "Download") Then
               Dim filename As String = e.CommandArgument.ToString
               'Dim path As String = Server.MapPath("~/RMAUploads/" & filename)
               Dim targetfolder As String = "\\" & ServerName & "\iPBR\Warranty\" & filename
               Response.AddHeader("Content-disposition", "attachment; filename=" & filename)
               Response.ContentType = "application/octet-stream"
           End If

  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 21 Apr 2015 Link to this post

    Hello Kevin,

    You can access the LinkButton in the ItemTemplate as described in the help topic below:

    and register it as postback control through the ScriptManager like this:

    I hope this helps.

    Maria Ilieva

    See What's Next in App Development. Register for TelerikNEXT.

  3. DevCraft R3 2016 release webinar banner
Back to Top