UploadedFiles.Count returns 0

Thread is closed for posting
4 posts, 0 answers
  1. Angel
    Angel avatar
    4 posts
    Member since:
    Apr 2013

    Posted 13 May 2013 Link to this post

    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) {
                   
                    }
                }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 May 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Angel
    Angel avatar
    4 posts
    Member since:
    Apr 2013

    Posted 14 May 2013 Link to this post

    Thanks Shinu, but it's not working i think the problem is due to AJAXMnager
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 15 May 2013 Link to this post

    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.
Back to Top