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

How to re-init RadUpload

2 Answers 82 Views
Upload
This is a migrated thread and some comments may be shown as answers.
zhivko.zhelezov
Top achievements
Rank 1
zhivko.zhelezov asked on 31 Oct 2011, 02:38 PM

I have the following scenario:

  1. The user goes to a page and uploads a document using RadUpload control
  2. Saves the current work (on the same page there are some other controls) and close the page– we get kind of URI for the uploaded file and store it.
  3. The user opens the page again, we should indicate somehow that the file is already uploaded, that’s why we developed small UserControl which we put on top of the RadUpload and disable the RadUpload as well.
  4. The user can close this little control and re-enable the RadUpload to upload a new document (this means that the first one is uploaded by mistake or for some reasons the user should upload a new one and remove the old document).

 

To have consistent UI we want to replace the default RadUpload appearance when 
a document is uploaded, but we don’t want to rewrite the entire Item template
because we are happy with the default one when we upload a document. That’s why
we developed small user control with a text “the document is already, click here
to open it” and remove button (x). When the removed button is pressed we just
hide this control and re-enable the RadUpload. My Idea was that I’ll show it when
the ppload is completed and it does work but below still is the default UI with
the uploaded file and the progress. I invoked the CancelUpload() method which
cleared the Items but the progress bar didn’t disappear. See the file attached.

I need exactly the same behavior that does the CancelButton – it clears the items
and removes the progress bar. I used the reflector to see the code and found the
property: private
RadUploadState State. but I didn't find a way to set it.
 
How I can re-init the control state? 

Best Regards
Kaloyan Nikolov

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 03 Nov 2011, 12:24 PM
Hello Zhivko.Zhelezov,

The RadUpload.CancelUpload() method sets the RadUpload in an initial state:

However, when you call it right after the upload has finished you might have to call it in a Dispatcher in order to make sure that the RadUpload state is restored to initial:
private void RadUpload1_UploadFinished(object sender, RoutedEventArgs e)
{
    this.Dispatcher.BeginInvoke(() =>
    {
        (sender as RadUpload).CancelUpload();
    });
}
Please give this a try and let us know if it helps.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
zhivko.zhelezov
Top achievements
Rank 1
answered on 03 Nov 2011, 02:00 PM
yep, this works fine.

Thank you.
Tags
Upload
Asked by
zhivko.zhelezov
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
zhivko.zhelezov
Top achievements
Rank 1
Share this question
or