Add back previous file list into radupload

11 posts, 1 answers
  1. Ervinna
    Ervinna avatar
    5 posts
    Member since:
    Jul 2010

    Posted 09 Mar 2011 Link to this post

    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
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 09 Mar 2011 Link to this post

    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!
  3. DevCraft banner
  4. Ervinna
    Ervinna avatar
    5 posts
    Member since:
    Jul 2010

    Posted 10 Mar 2011 Link to this post

    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.
  5. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 10 Mar 2011 Link to this post

    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!
  6. Ervinna
    Ervinna avatar
    5 posts
    Member since:
    Jul 2010

    Posted 10 Mar 2011 Link to this post

    Hi Alex Fidanov,

    Yes. work well now after upgrate to Q3. thanks.
  7. Raja
    Raja avatar
    3 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    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
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Sep 2012 Link to this post

    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.

  9. Raja
    Raja avatar
    3 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2012 Link to this post

    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
  10. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 24 Sep 2012 Link to this post

    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.

  11. Raja
    Raja avatar
    3 posts
    Member since:
    Sep 2012

    Posted 25 Sep 2012 Link to this post

    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
  12. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 27 Sep 2012 Link to this post

    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.

Back to Top
DevCraft banner