How to re-init RadUpload

3 posts, 1 answers
  1. zhivko.zhelezov
    zhivko.zhelezov avatar
    31 posts
    Member since:
    May 2011

    Posted 31 Oct 2011 Link to this post

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

    Posted 03 Nov 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. zhivko.zhelezov
    zhivko.zhelezov avatar
    31 posts
    Member since:
    May 2011

    Posted 03 Nov 2011 Link to this post

    yep, this works fine.

    Thank you.
Back to Top