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

UploadedFiles.Count returns 0

3 Answers 90 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Angel
Top achievements
Rank 1
Angel asked on 13 May 2013, 03:33 PM
I'm using a RadUpload in radwindow and when I check the UploadedFiles.Count within my InsertCommand, it returns 0.  Any ideas what I'm doing wrong?

 <telerik:RadUpload ID="RUImg" runat="server" InitialFileInputsCount="1" Width="340">
  </telerik:RadUpload>

code behind

    foreach (UploadedFile file in RUImg.UploadedFiles)
            {
                try
                {
                    file.SaveAs("D:\\Projet\\Intranet\\O2-PowerNet\\images_app\\AnnonceImages\\" + file.GetName(), true);

                }
                catch (Exception ex) {
               
                }
            }

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2013, 06:02 AM
Hi Angel,

Please have a look at the following code I tried which works fine at my end.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="false" Text="Open RadWindow"
    OnClientClicked="OnClientClicked">
</telerik:RadButton>
<br />
<br />
<asp:Label ID="Label1" runat="server">
</asp:Label>
<telerik:RadWindow ID="RadWindow1" runat="server" Width="500px" Height="400px">
    <ContentTemplate>
        <telerik:RadUpload ID="RUImg" runat="server" InitialFileInputsCount="1" Width="340"
            Style="margin: 20px 0px 0px 20px;">
        </telerik:RadUpload>
        <br />
        <br />
        <telerik:RadButton ID="RadButton2" runat="server" OnClick="RadButton2_Click" Text="Upload Files"
            Style="margin: 0px 0px 0px 20px;">
            <Icon PrimaryIconCssClass="rbUpload" />
        </telerik:RadButton>
    </ContentTemplate>
</telerik:RadWindow>

C#:
protected void RadButton2_Click(object sender, EventArgs e)
{
    int count = RUImg.UploadedFiles.Count;
    Label1.Text = count + " Files Uploaded<br/><br/>";
    foreach (UploadedFile file in RUImg.UploadedFiles)
    {
        try
        {
            file.SaveAs("D:\\Projet\\Intranet\\O2-PowerNet\\images_app\\AnnonceImages\\" + file.GetName(), true);
 
        }
        catch (Exception ex)
        {
 
        }
    }
}

Thanks,
Shinu.
0
Angel
Top achievements
Rank 1
answered on 14 May 2013, 08:48 AM
Thanks Shinu, but it's not working i think the problem is due to AJAXMnager
0
Genady Sergeev
Telerik team
answered on 15 May 2013, 12:58 PM
Hello,

Uploading files with AJAX is not supported with RadUpload. However, it is possible using RadAsyncUpload. I suggest that you migrate to RadAsyncUpload should you need to upload files with AJAX.

Kind regards,
Genady Sergeev
the Telerik team
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 their blog feed now.
Tags
Upload (Obsolete)
Asked by
Angel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Angel
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or