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

How to UnRegister EventManager?

3 Answers 345 Views
Upload
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 22 May 2014, 11:33 PM
  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.


3 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 27 May 2014, 11:55 AM
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.
 
0
danparker276
Top achievements
Rank 2
answered on 27 May 2014, 04:44 PM
I get an error saying that it wants type System.Windows.RoutedEvent  for RadUploadItem.ValidateEvent
0
danparker276
Top achievements
Rank 2
answered on 27 May 2014, 04:58 PM
Sorry, I see I have to add 
using Telerik.Windows;

Tags
Upload
Asked by
danparker276
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or