ValidateEvent handler

1 posts, 0 answers
  1. Radu
    Radu avatar
    3 posts
    Member since:
    Nov 2010

    Posted 07 Jun 2011 Link to this post

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



Back to Top