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

ValidateEvent handler

0 Answers 67 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Radu
Top achievements
Rank 1
Radu asked on 07 Jun 2011, 01:03 PM
----------------------------
Fixed by adding reference to
using Telerik.Windows;

as in http://www.telerik.com/community/forums/silverlight/menu/silverlight-3.aspx  
------------------------------

Hello,
I was trying to add item validation to the RadUpload. The XAML control is called RadUpload1. I have coded the snippet from the official documentation from http://www.telerik.com/help/silverlight/radupload-features-upload-validation.html and I noticed my version has a different number of attributes :
       
RadUpload1.AddHandler( RadUploadItem.ValidateEvent, new UploadValidateEventHandler( RadUploadItem_OnValidate ), false );
instead of the one in your documentation: radUpload.AddHandler(RadUploadItem.ValidateEvent, new UploadValidateEventHandler(OnValidate)); ... My handler implementation:
private void RadUploadItem_OnValidate( object sender, UploadValidateEventArgs e ) {
    string fileExtension = ( e.OriginalSource as RadUploadItem ).FileName;
    if( !fileExtension.EndsWith( ".csv" ) || !fileExtension.EndsWith( ".txt" ) ) {
        e.ErrorMessage = "Cannot upload this image! Please select either a Comma Separated Value (csv) or a Text (txt) file.";
        e.Cancel = true;
    }
}

When implementing the handler as above I get this error at design time:

The best overloaded method match for 'System.Windows.UIElement.AddHandler(System.Windows.RoutedEvent, System.Delegate, bool)' has some invalid arguments 

Side suggestion : mark in the documentation also the version of controls to which it reffers and add links for previous versions documentation.

Regards,
Radu



No answers yet. Maybe you can help?

Tags
Upload
Asked by
Radu
Top achievements
Rank 1
Share this question
or