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

Add back previous file list into radupload

10 Answers 132 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ervinna
Top achievements
Rank 1
Ervinna asked on 09 Mar 2011, 09:52 AM
Hi,

i have a radupload that will perform a validate some fields value before upload the file. Wen the validation return false, i will cancel the upload and i want to get back the file list and display back to the radupload after cancel the upload. The reupload function return me an error.

{System.NullReferenceException: Object reference not set to an instance of an object.
   at DragDropUpload.MainPage.ReUploadItems()}

what wrong of the code? and how can i display back the list of file that browsed?

The code example are below:-

Private Sub RadUpload1_UploadStarted(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.UploadStartedEventArgs) Handles RadUpload1.UploadStarted
        Dim list As New ObservableCollection(Of MyDatabaseService.clsImportDoc)
 
        Try
 
            If Not FormBase Is Nothing Then
                Dim dgPF As New Grid
                dgPF = CType(FormBase.FindName("dgProfileFields"), Grid)
 
                For i As Integer = 0 To dgPF.Children.Count - 1
 
                    If TypeOf (dgPF.Children.Item(i)) Is TextBox Then
                        Dim txtPF As New TextBox
                        txtPF = CType(dgPF.Children.Item(i), TextBox)
 
                        list.Add(New clsImportDoc With {.ProfileFieldsNames = txtPF.Name.ToString, .ProfileFieldValues = txtPF.Text.ToString, .ProfileID = ddpProfile.SelectedValue})
                    ElseIf TypeOf (dgPF.Children.Item(i)) Is RadDatePicker Then
                        Dim rdpPF As New RadDatePicker
                        rdpPF = CType(dgPF.Children.Item(i), RadDatePicker)
 
                        list.Add(New clsImportDoc With {.ProfileFieldsNames = rdpPF.Name.ToString, .ProfileFieldValues = rdpPF.DateTimeText.ToString, .ProfileID = ddpProfile.SelectedValue})
                    End If
                Next
            End If
 
            AddHandler client.fValidateIndexValueCompleted, AddressOf client_fValidateIndexValueCompleted
            client.fValidateIndexValueAsync(list)
 
        Catch ex As Exception
            client.sWriteErrorLogAsync("RadUpload1_UploadStarted (MainPage Silverlight Import) : " & ex.Message)
        End Try
 
    End Sub
 
 Private Sub client_fValidateIndexValueCompleted(ByVal sender As Object, ByVal e As fValidateIndexValueCompletedEventArgs)
        Dim strValidateResult As String = ""
 
        Try
 
            strValidateResult = e.Result
 
            If strValidateResult <> "1" Then
                lblErrorMessage.Visibility = Windows.Visibility.Visible
                lblErrorMessage.Content = strValidateResult
 
                SaveFiles()
                RadUpload1.CancelUpload()
                ReUploadItems()               
            End If
 
        Catch ex As Exception
            client.sWriteErrorLogAsync("client_fValidateIndexValueCompleted (MainPage Silverlight Import) : " & ex.Message)
        End Try
 
    End Sub
 
Private files As New List(Of FileInfo)()
     
    Private Sub ReUploadItems()
        '/ put the files back in the upload
        Try
                       
            If files.Count > 0 Then
                For Each file As FileInfo In files
                    Dim f As New RadUploadSelectedFile(file)
                    RadUpload1.CurrentSession.SelectedFiles.Add(f)
                Next               
            End If
 
        Catch ex As Exception
 
        End Try
    End Sub
 
    Private Sub SaveFiles()
        '/ get the files from the upload.
        'Dim files As New List(Of FileInfo)()
        files.Clear()
        For Each item As Object In RadUpload1.CurrentSession.SelectedFiles
            files.Add(item.File)
        Next
    End Sub

10 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 09 Mar 2011, 05:46 PM
Hi Ervinna,

Please take a look at the approach from this forum post here. Let us know if that is what you are trying to achieve.

Greetings,
Alex Fidanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Ervinna
Top achievements
Rank 1
answered on 10 Mar 2011, 08:30 AM
Hi Alex Fidanov,

I'm also got see this approach but i can't figure the idea how to done it. when i put the 'RadUpload1.PrepareSelectedFilesForUpload()' in my project, i get " 'PrepareSelectedFilesForUpload' is not a member of 'telerik.windows.controls.radupload'. ".i got Imports Telerik.Windows.Controls but does not help. i'm using silverlight 4 Q2 2010. 

Do you have any sample to archive this?

thanks.
0
Accepted
Alex Fidanov
Telerik team
answered on 10 Mar 2011, 08:48 AM
Hello Ervinna,

This method was introduced in a later version than Q2 to facilitate manipulating the upload items with procedural code. If it is possible for you to upgrade to Q3 and test this?

All the best,
Alex Fidanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Ervinna
Top achievements
Rank 1
answered on 11 Mar 2011, 04:48 AM
Hi Alex Fidanov,

Yes. work well now after upgrate to Q3. thanks.
0
Raja
Top achievements
Rank 1
answered on 13 Sep 2012, 08:42 PM
Hi,

I am looking for C# code to add the files manually to the RadUpload control.  Per this example, there is a way to add files in VB.net.  Please let me know if there is a possibility to do that in C#.  This is something urgent to do.

thanks
raja
0
Tina Stancheva
Telerik team
answered on 18 Sep 2012, 03:45 PM
Hi Raja,

You can examine this article to see how to create a custom RadUpload control manually adding a list of files. The code snippets are both in C# and VB.NET so you can use the C# examples.

Let me know if that helps or if you need more information.

Regards,
Tina Stancheva
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Raja
Top achievements
Rank 1
answered on 19 Sep 2012, 06:25 PM
Hi Tina,

Thanks for your response!

I am trying to acheive this functionality for Web Controls(aspx).  can you please let me know the namespace that i can use to implement this piece in Web Forms instead of Windows?

Thanks
Raja
0
Kate
Telerik team
answered on 24 Sep 2012, 12:48 PM
Hi Raja,

Can you please clarify if you refer to the RadUpload for Silverlight or the one from the ASP.NET AJAX suit, since the article from the previous post concerns the Silverlight control?

All the best,
Kate
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Raja
Top achievements
Rank 1
answered on 25 Sep 2012, 07:43 PM
Hi Kate,

I am looking for code(C# and ASP.net) that will help me to add the file into RadUpload control basically web application. 

Thanks
Raja
0
Kate
Telerik team
answered on 27 Sep 2012, 08:48 AM
Hi Raja,

Unfortunately with the RadUpload control you can not manually add files to the control. Since it is a security limitation, in order to add files to the control you will need to use the dialog window and choose the files that you will be uploading. You can also refer to our on-line demos for more and detailed examples:
http://demos.telerik.com/aspnet-ajax/upload/examples/overview/defaultcs.aspx

Kind regards,
Kate
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
Upload
Asked by
Ervinna
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Ervinna
Top achievements
Rank 1
Raja
Top achievements
Rank 1
Tina Stancheva
Telerik team
Kate
Telerik team
Share this question
or