download file in Ajax Panel

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

     

    <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

  2. Maria Ilieva
    Admin
    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:
    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.

     
  3. jajanes
    jajanes avatar
    5 posts
    Member since:
    Sep 2006

    Posted 28 Jan in reply to Maria Ilieva Link to this post

    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).  
  4. Vessy
    Admin
    Vessy avatar
    2011 posts

    Posted 29 Jan Link to this post

    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.
  5. jajanes
    jajanes avatar
    5 posts
    Member since:
    Sep 2006

    Posted 29 Jan in reply to Vessy Link to this post

    Indeed it does, I was mixing up the RadAjaxManager and RadScriptManager.  
Back to Top