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

RadAjaxManagerProxy & FileUpload

1 Answer 73 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Andrea D'Orio
Top achievements
Rank 1
Andrea D'Orio asked on 05 Feb 2009, 03:05 PM
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

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Feb 2009, 07:48 AM
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.
Tags
Ajax
Asked by
Andrea D'Orio
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or