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

UploadedFiles.Count returns 0

11 Answers 500 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 15 Mar 2008, 09:57 PM
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

11 Answers, 1 is accepted

Sort by
0
Accepted
Sophy
Telerik team
answered on 17 Mar 2008, 08:41 AM
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
0
Accepted
JJ
Top achievements
Rank 1
answered on 17 Mar 2008, 01:07 PM
Perfect!  That's exactly what I needed.  I'm so glad you included the sample in your reply.

Once again, great job!!!

Jeff
0
JJ
Top achievements
Rank 1
answered on 17 Mar 2008, 06:36 PM
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
0
Sophy
Telerik team
answered on 18 Mar 2008, 01:32 PM
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
0
Rick Hubka
Top achievements
Rank 1
answered on 06 May 2009, 01:17 AM
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
0
Alisson
Top achievements
Rank 1
answered on 07 May 2009, 09:17 PM
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

 

 

0
vadim yakovlev
Top achievements
Rank 1
answered on 24 Mar 2010, 04:12 PM
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)" /> 
0
Brett
Top achievements
Rank 1
answered on 15 Aug 2012, 05:22 PM
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?   
0
Peter Filipov
Telerik team
answered on 16 Aug 2012, 03:24 PM
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.
0
Brett
Top achievements
Rank 1
answered on 16 Aug 2012, 03:27 PM
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.
0
Peter Filipov
Telerik team
answered on 21 Aug 2012, 01:50 PM
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.
Tags
Upload (Obsolete)
Asked by
JJ
Top achievements
Rank 1
Answers by
Sophy
Telerik team
JJ
Top achievements
Rank 1
Rick Hubka
Top achievements
Rank 1
Alisson
Top achievements
Rank 1
vadim yakovlev
Top achievements
Rank 1
Brett
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or