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

Ajax manager and Response to file downloads

3 Answers 55 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lucas
Top achievements
Rank 1
Lucas asked on 24 Sep 2013, 04:56 PM
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.     

pAGE:
 <form ID="FormPnale" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"/>                              
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
              <AjaxSettings>                
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                  <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="TextNotifi" />                        
                  </UpdatedControls>
                </telerik:AjaxSetting>                
              </AjaxSettings>
            </telerik:RadAjaxManager>
            <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" />
                    </div>         
                    <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" />
                        <div>    
                             <asp:LinkButton runat="server" ID="TrocarLkBtn" Text="Trocar Senha" />
                        <br/>
                             <asp:LinkButton runat="server" ID="VoltarLkBtn" Text="Voltar" />                
                        </div>
                    </div>
                    <div id="main">                       
                        <div id="Upload">                
                            <asp:LinkButton ID="IncluirBtn" runat="server" OnClientClick="javascript:OpenFTPWnd();return false;" Text="Acessar FTP" />                             
                        </div>
                        <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" >                                                     
                                <Columns>
                                    <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"/>                                                        
                                </Columns>                                                                     
                            </MasterTableView>    
                            <SortingSettings SortedBackColor="Transparent" EnableSkinSortStyles="false" />                                               
                            <PagerStyle PageSizeControlType="RadComboBox" AlwaysVisible="true"/>
                            <ClientSettings EnableRowHoverStyle="true" AllowRowsDragDrop="True"/> 
                        </telerik:RadGrid>               
                    </div>    
                </div>  
            </div>  
             <telerik:RadWindowManager ID="RadWindowsManager1" runat="server" Behaviors="Move" VisibleStatusbar="false" style="z-index:90000" ShowContentDuringLoad="false" modal="true" ReloadOnShow="true">
                <Windows>
                    <telerik:RadWindow runat="server" ID="FTPWnd" Behaviors="Close"/>                   
                </Windows>
            </telerik:RadWindowManager>
             <telerik:RadNotification ID="TextNotifi" runat="server" Position="TopCenter" OffsetY="30" Skin="Office2010Blue" 
            Width="300px" EnableRoundedCorners="true" Height="88px" AutoCloseDelay="30000" KeepOnMouseOver="False"/>            
        </form>     
    </body>

CODE  Behind:

   If e.CommandName = "Down" Then

            'Processo não funciona com arquivos grandes
            Try
                '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")
                Response.End()

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

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Sep 2013, 12:39 PM
Hello,

Please try with the below code snippet.

<script type="text/javascript">
            function onRequestStart(sender, args) {
                if (args.get_eventTarget().indexOf("Download") >= 0) {
                    args.set_enableAjax(false);
                }
            }
        </script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
          <ClientEvents OnRequestStart="onRequestStart" />
          
      </telerik:RadAjaxManager>
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";
        }
    }


Thanks,
Jayesh Goyani
0
Lucas
Top achievements
Rank 1
answered on 26 Sep 2013, 01:30 PM
No, the error continue. 
0
Eyup
Telerik team
answered on 27 Sep 2013, 08:07 AM
Hi Lucas,

You can refer to the following topics for uploading/downloading with ajaxified controls:
http://www.telerik.com/help/aspnet-ajax/ajax-ajax-and-upload.html
http://www.telerik.com/help/aspnet-ajax/upload-uploading-ajax.html

Hope this helps.

Regards,
Eyup
Telerik
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.
Tags
Ajax
Asked by
Lucas
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Lucas
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or