This is a migrated thread and some comments may be shown as answers.

download file in Ajax Panel

4 Answers 54 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 16 Apr 2015, 07:38 PM

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.

 

<DetailTables>
                               <telerik:GridTableView DataKeyNames="intUploadId" Name="SubGrid" Width="50%" TableLayout="Fixed" Font-Size="10" AutoGenerateColumns="False" SkinID="Web20">
                                       <ParentTableRelation>
                                           <telerik:GridRelationFields DetailKeyField="intWarrantyNumId" MasterKeyField="intWarrantyNumId" />
                                       </ParentTableRelation>
                                       <HeaderStyle Font-Bold="true" HorizontalAlign="Center" />
                                       <ItemStyle HorizontalAlign="Center"  />
                                       <AlternatingItemStyle HorizontalAlign="Center" />
                                       <Columns>
                                            <telerik:GridTemplateColumn HeaderText="File">
                                                <ItemTemplate>
                                                    <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" />
                                                    </asp:LinkButton>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>  
                                            <telerik:GridTemplateColumn HeaderText="File">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkFile" runat="server" Text='<%# Bind("strLocation")%>' CommandArgument='<%# Bind("strLocation")%>' CommandName="Download"></asp:LinkButton>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>  
                                       </Columns>
                               </telerik:GridTableView>
                           </DetailTables>
 
 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"
           Response.WriteFile(targetfolder)
           Response.End()
       End If

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 21 Apr 2015, 10:51 AM
Hello Kevin,

You can access the LinkButton in the ItemTemplate as described in the help topic below:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

and register it as postback control through the ScriptManager like this:
RadScriptManager1.RegisterPostBackControl(LinkButton1);

I hope this helps.

Regards,
Maria Ilieva
Telerik
 

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

 
0
jajanes
Top achievements
Rank 1
answered on 28 Jan 2019, 08:35 PM
How is this done in current (2018+) version of the Telerik RadScriptManger, ".RegisterPostBackControl()" is not an option (an least not an option that intellisense is showing me).  
0
Vessy
Telerik team
answered on 29 Jan 2019, 07:36 AM
Hi jajanes,

The RegisterPostBackControl() method of RadScriptManager is still available - it can be accessed through the ID of RadScriptManager as follows:
https://www.screencast.com/t/59go1Lo6

Make sure that the ID of the Control does not match its class (RadScriptManager) and that you are using the ID to access the needed method.

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
jajanes
Top achievements
Rank 1
answered on 29 Jan 2019, 05:00 PM
Indeed it does, I was mixing up the RadAjaxManager and RadScriptManager.  
Tags
Ajax
Asked by
Kevin
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
jajanes
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or