UploadedFiles.Count returns 0

Thread is closed for posting
12 posts, 2 answers
  1. JJ
    JJ avatar
    21 posts
    Member since:
    Jan 2008

    Posted 15 Mar 2008 Link to this post

    I'm using a RadUpload in an EditTemplate of a RadGrid and when I check the UploadedFiles.Count within my InsertCommand, it returns 0.  Any ideas what I'm doing wrong?

            RadGrid rgRotator = (RadGrid)sender;
            RadUpload ruThumbnail = (RadUpload)e.Item.FindControl("ruThumbnail");

            if (ruThumbnail.UploadedFiles.Count > 0)
            {
                // execute SaveAs
            }



    Thanks,

    Jeff
  2. Answer
    Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 17 Mar 2008 Link to this post

    Hello Jeff,

    Do you use AJAX for updating the RadGrid and uploading the selected files? One of the known limitation of the RadUpload control is that it cannot upload files using AJAX calls and if you try to upload files with AJAX calls  the UploadedFiles collection will be empty. You can find more details about the problem and some workarounds in this help article. For your convenience I have also attached an example demonstrating how to use RadUpload in an Ajaxified Grid.

    Please, let us know if you need further assistance.

    Best wishes,
    Sophy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    JJ
    JJ avatar
    21 posts
    Member since:
    Jan 2008

    Posted 17 Mar 2008 Link to this post

    Perfect!  That's exactly what I needed.  I'm so glad you included the sample in your reply.

    Once again, great job!!!

    Jeff
  5. JJ
    JJ avatar
    21 posts
    Member since:
    Jan 2008

    Posted 17 Mar 2008 Link to this post

    Hi Sophy,

    One more question.  Is there a way to use a RadAjaxManager along with a RadAjaxLoadingPanel in this scenario?  When I try to implement one, the RadUpload control doesn't render.

    Thanks,

    Jeff
  6. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 18 Mar 2008 Link to this post

    Hello,

    There should not be any problem implementing the same functionality with RadAjaxManager and RadAjaxLoadingPanel. Please, find attached a modified version of the same example so that it uses RadAjaxManager and RadAjaxLoadingPanel.

    If you expereince any problems, please, let us know.

    All the best,
    Sophy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Rick Hubka
    Rick Hubka avatar
    33 posts
    Member since:
    Apr 2006

    Posted 05 May 2009 Link to this post

    Thanks for the code downloads examples Sophy

    I have to say, they are the best I have found on the forum to date.  That says a lot because I have tried 100's of sample downloads in the last 2 years.  What sets them apart from the rest is:
    1) They are not exact copies from the Telerik Live demos folder that will not run unless you modify them for 10 minutes.
    2) They came with a database that works with the sample.
    3) The database was updatable with the example code, thus representing a real working example.
    4) These last 2 examples actually had image folder that again helped showed a real working example.
    5) The code worked immediately with no editing.
    6) Again...  It just works.

    Thanks again

    Rick Hubka
  8. Alisson
    Alisson avatar
    1 posts
    Member since:
    Apr 2009

    Posted 07 May 2009 Link to this post

    if you are using master pages, the $find(window['UploadId']) will return always null;
    So, I made a sligth modification in the Javascript that finds the input element and checks if it has a value ...

     Here is my conditionalPostback function : 

     

        function conditionalPostback(e, sender) {  
     
                            var theRegexp = new RegExp ("\.UpdateButton$|\.PerformInsertButton$""ig");  
     
                            if (sender.EventTarget.match(theRegexp)) {  
                                var uploadFile = document.getElementById(window['UploadId']).value;  
     
                                //AJAX is disabled only if file is selected for upload  
                                if (uploadFile != "") {  
                                    sender.EnableAjax = false;  
                                }  
                            }  
                        }      
     
     


    Hope it helps!

    Alisson Santana

     

     

  9. vadim yakovlev
    vadim yakovlev avatar
    1 posts
    Member since:
    Mar 2010

    Posted 24 Mar 2010 Link to this post

    I had the same problem with using the RadUpload inside the UpdatePanel  and I found a solution.

    What actually worked for me was including the ID of the "Upload File(s)" (just a regular asp.net button) in the <Triggers> of the ASP.net AJAX UpdatePanel  as PostBackTrigger.

    <asp:UpdatePanel ChildrenAsTriggers="true" ID="UpdatePanel1"   
         runat="server">  
       <Triggers> 
           
         <asp:PostBackTrigger ControlID="btnAttach" />    
     
    ...  
     
     
     
    <telerik:RadUpload ID="RadUploadAttachment" runat="server"         
                         ControlObjectsVisibility="RemoveButtons, AddButton">  
                    </telerik:RadUpload> 
     
     <asp:Button ID="btnAttach" runat="server" CausesValidation="false" 
                     OnClick="Click_Attach" Text="Attach file(s)" /> 
  10. Brett
    Brett avatar
    12 posts
    Member since:
    May 2012

    Posted 15 Aug 2012 Link to this post

    Is there a way to make this work with an ASP Datalist?   I see that there is a reference to <ClientEvents>, is that a Telerik only thing?   
  11. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 16 Aug 2012 Link to this post

    Hi Brett,

    It is possible to get it work with DataList control. You need to place the RadUpload control in the DataList ItemTemplate and bind the control. In case that you have other questions regarding that scenario, please open a support ticket in order to keep the consistency of the thread.

    Kind regards,
    Peter Filipov
    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.
  12. Brett
    Brett avatar
    12 posts
    Member since:
    May 2012

    Posted 16 Aug 2012 Link to this post

    Hi Peter - in this case the consistency comes from the face that the count is returning 0.   I have put the RadFileUpload into an ItemTemplate and am binding the data, that part is working fine.   However it is still returning 0, and it seems clear that the information provided in this thread is the key to fixing it - basically that AJAX needs to get disabled.  However they are doing it using RadAjaxManager and I don't know if that can apply to DataList and ItemTemplate.  If you still think that is not related I can go create another support ticket.
  13. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 21 Aug 2012 Link to this post

    Hi Brett,

    Thank you for clarifying the details regarding your project because I was not sure about your case. I prepared a sample page you. Please review the attachment.

    Regards,
    Peter Filipov
    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
UI for ASP.NET Ajax is Ready for VS 2017