How to UnRegister EventManager?

4 posts, 1 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 22 May 2014 Link to this post

      So I have 2 pages that use.  I need to validate 2 different check boxes.
              Telerik.Windows.EventManager.RegisterClassHandler(typeof(RadUploadItem), RadUploadItem.ValidateEvent, new UploadValidateEventHandler(OnValidate));

    So I guess I could put this on the master pages, but I have 2 different views that use a different upload control.  How do I unregister the above command, so if I hit that page 10 times, I got 10 different event handlers it goes through.


  2. Answer
    Martin
    Admin
    Martin avatar
    1099 posts

    Posted 27 May 2014 Link to this post

    Hi Dan,

    Note that the EventManager doesn't have an UnregisterClassHandler method. This is why it is recommended that the RegiesterClassHandler() method to be called in the static constructor of the page. This will apply the handler to all instances of the RadUploadItem only once. 

    Another approach that you can use it to register/unregister the event handler using the AddHandler method of the RadUpload control. Here is an example in code:
    this.myRadUpload.RemoveHandler(RadUploadItem.ValidateEvent, new UploadValidateEventHandler(OnValidate));
    this.myRadUpload.AddHandler(RadUploadItem.ValidateEvent, new UploadValidateEventHandler(OnValidate));

    Let me know if you have any further questions.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 27 May 2014 in reply to Martin Link to this post

    I get an error saying that it wants type System.Windows.RoutedEvent  for RadUploadItem.ValidateEvent
  5. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 27 May 2014 in reply to danparker276 Link to this post

    Sorry, I see I have to add 
    using Telerik.Windows;

Back to Top