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.


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

    Posted 28 Jan 2019 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
    Vessy avatar
    2070 posts

    Posted 29 Jan 2019 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:

    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.

    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 2019 in reply to Vessy Link to this post

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