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

Cancel Button

1 Answer 13 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Ovidiu
Top achievements
Rank 1
Ovidiu asked on 16 Aug 2012, 06:51 PM
Hi all

I want to do something at "Cancel" button (e.g. close the browser window) after everything it's uploaded.
Thanks

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 21 Aug 2012, 11:55 AM
Hi Ovidiu,

The RadUpload control exposes a DelegateCommand which is executed when the Cancel button is clicked. This means that you can define a custom execution method for the command thus customizing the default Cancel button behavior:
<telerik:RadUpload x:Name="xRadUpload"
    TargetFolder="UserUploads"
    UploadServiceUrl="/UserUploadHandler.ashx"
    UploadFinished="xRadUpload_UploadFinished"/>
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
        xRadUpload.CancelCommand = new DelegateCommand((p) => CustomCancelCommand());
    }
 
    private void CustomCancelCommand()
    {
        if (!this.isUploadFinished)
            xRadUpload.CancelUpload();
        else
        {
            HtmlPage.Window.Invoke("close");
        }
 
    }
    bool isUploadFinished;
    private void xRadUpload_UploadFinished(object sender, System.Windows.RoutedEventArgs e)
    {
        this.isUploadFinished = true;
    }
}

Please give this a try and let me know if it helps or if we can further assist you.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Upload
Asked by
Ovidiu
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or