Ajax manager and Response to file downloads

4 posts, 0 answers
  1. Lucas
    Lucas avatar
    4 posts
    Member since:
    Aug 2013

    Posted 24 Sep 2013 Link to this post

    Hi, I have a problem with ajax maneger that does not work with command response, but I need to use the response to the Transmit files.     

     <form ID="FormPnale" runat="server">
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server"/>                              
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="TextNotifi" />                        
                <div id="page" style="width:auto">
                    <div id="header">
                        <div id="tittle">
                            <asp:Label runat="server" ID="HeaderLbl" text="Projeto DocRocket" Font-Size="30pt" /> <br/>  
                            <asp:Label  runat="server" ID="LblAcervo" Font-Size="20pt" Visible="false" meta:resourceKey="LblAcervo" />
                        <br />
                        <br /> 
                        <div id="loginDisplay" style="text-align:right" >                        
                            <asp:Label runat="server" ID="Loginlbl" Text="Seja bem vindo," />                 
                            <asp:LoginName ID="HeadLoginName" runat="server" />
                                 <asp:LinkButton runat="server" ID="TrocarLkBtn" Text="Trocar Senha" />
                                 <asp:LinkButton runat="server" ID="VoltarLkBtn" Text="Voltar" />                
                        <div id="main">                       
                            <div id="Upload">                
                                <asp:LinkButton ID="IncluirBtn" runat="server" OnClientClick="javascript:OpenFTPWnd();return false;" Text="Acessar FTP" />                             
                            <div id="ErrorMessage" runat="server" style="text-align: center;" />
                            <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0" GridLines="None"  >
                                <MasterTableView AutoGenerateColumns="false" AllowSorting="true" ClientDataKeyNames="Pasta, Down" PageSize="20" CommandItemDisplay="Top" 
                                CommandItemSettings-ShowAddNewRecordButton="false" >                                                     
                                        <telerik:GridBoundColumn UniqueName="ClNome" DataField="Nome" HeaderText="Nome" />
                                        <telerik:GridBoundColumn UniqueName="ClPasta" DataField="Pasta" HeaderText="Pasta" />
                                        <telerik:GridBoundColumn UniqueName="ClData" DataField="Data" HeaderText="Data" />
                                        <telerik:GridBoundColumn UniqueName="ClPag" DataField="Paginas" HeaderText="Páginas" />                            
                                        <telerik:GridBoundColumn UniqueName="ClEstado" DataField="Estado" HeaderText="Estado" />                                             
                                        <telerik:GridButtonColumn CommandName="Down" UniqueName="ClDown"  meta:resourceKey="DownLnk" />                                                        
                                        <telerik:GridButtonColumn CommandName="Delete" UniqueName="ClDelete" ConfirmDialogType="RadWindow" ConfirmText="Delete ?" ConfirmDialogHeight="25px" ConfirmDialogWidth="250px" ConfirmTitle="Delete" meta:resourceKey="DeleteLnk"/>                                                        
                                <SortingSettings SortedBackColor="Transparent" EnableSkinSortStyles="false" />                                               
                                <PagerStyle PageSizeControlType="RadComboBox" AlwaysVisible="true"/>
                                <ClientSettings EnableRowHoverStyle="true" AllowRowsDragDrop="True"/> 
                 <telerik:RadWindowManager ID="RadWindowsManager1" runat="server" Behaviors="Move" VisibleStatusbar="false" style="z-index:90000" ShowContentDuringLoad="false" modal="true" ReloadOnShow="true">
                        <telerik:RadWindow runat="server" ID="FTPWnd" Behaviors="Close"/>                   
                 <telerik:RadNotification ID="TextNotifi" runat="server" Position="TopCenter" OffsetY="30" Skin="Office2010Blue" 
                Width="300px" EnableRoundedCorners="true" Height="88px" AutoCloseDelay="30000" KeepOnMouseOver="False"/>            

    CODE  Behind:

       If e.CommandName = "Down" Then

                'Processo não funciona com arquivos grandes
                    'Passar um parametro de Pasta
                    Dim Pasta As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("Pasta").ToString()


                    'configurando o botão Down para fazer download do executavei para o usuário.
                    Response.ContentType = "application/octet-stream"
                    Response.AppendHeader("Content-Disposition", "attachment; filename=" & Pasta & ".exe")
                    Response.TransmitFile(node.Attributes("path").Value & "\" & Usuario & "\$FTP$\Saida\" & Pasta & ".exe")

                Catch ex As Exception
                    TextNotifi.Title = Convert.ToString(GetGlobalResourceObject("CommonText", "Error"), CultureInfo.CurrentCulture)
                    TextNotifi.Text = ex.Message
                    e.Canceled = True
                    Exit Sub
                End Try
            End If

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 26 Sep 2013 Link to this post


    Please try with the below code snippet.

    <script type="text/javascript">
                function onRequestStart(sender, args) {
                    if (args.get_eventTarget().indexOf("Download") >= 0) {
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
              <ClientEvents OnRequestStart="onRequestStart" />
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            if (e.Item is GridDataItem)
                GridDataItem item = e.Item as GridDataItem;
                (item["ClDown"].Controls[0]).ID = "Download";

    Jayesh Goyani
  3. Lucas
    Lucas avatar
    4 posts
    Member since:
    Aug 2013

    Posted 26 Sep 2013 Link to this post

    No, the error continue. 
  4. Eyup
    Eyup avatar
    4081 posts

    Posted 27 Sep 2013 Link to this post

    Hi Lucas,

    You can refer to the following topics for uploading/downloading with ajaxified controls:

    Hope this helps.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top