RadAjaxManagerProxy & FileUpload

2 posts, 0 answers
  1. Andrea D'Orio
    Andrea D'Orio avatar
    12 posts
    Member since:
    Mar 2007

    Posted 05 Feb 2009 Link to this post

    Hi,
    I have an issue when use RadAjaxManagerProxy to create loading effect and FileUpload control. Following my code:

    #.aspx

        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnImporta">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="lblStatus"/>
                    </UpdatedControls>
                </telerik:AjaxSetting>           
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>

       <div style="padding-left:10px">
            <br />
            <asp:Label ID="lblCaption" runat="server"
                Text="Seleziona il file XML da importare: " ></asp:Label>
            <asp:FileUpload ID="fileUpload" runat="server" Width="300px"/>
            <br />        
            <br /><asp:Button ID="btnImporta" runat="server" onclick="Importa_Click" Text="Importa Dati" />
            &nbsp;
                        
            <asp:Label ID="lblStatus" runat="server"
                Text=""></asp:Label>
        </div>

    #.cs

            protected void Importa_Click(object sender, EventArgs e)
            {
                if (fileUpload.HasFile)
                {
                    try
                    {
                        // Save file to tmp folder
                        fileUpload.PostedFile.SaveAs(TmpFile);
                       
                        // Import data
                        ImportData();                   
                    }
                    catch(Exception ex)
                    {                  
                    }
                    finally
                    {
                     
                    }
                }
            }

    I select my file, then click on "btnImporta" button: loading image appears and click event is fired but "fileUpload.HasFile" is false. Seems that after postback fileUpload control lost its reference. I try also setting EnableViewState=false but not work.
    Do you have any suggestion?

    Thanks a lot in advance
  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 09 Feb 2009 Link to this post

    Hi Andrea,

    I'm afraid that uploading files during ajax request is not possible due to the nature of xHTTPRequest object. Thus in order to upload file you should disable the ajax and use normal postbacks. For more information please refer to this help article.

    Regards,
    Rosen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top