Two ways to do this:
If your AsyncFileUpload1
variable has the WithEvents
qualifier, you can do the following using the Handles keyword on the event handler itself:
Private Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AsyncFileUploadEventArgs) Handles AsyncFileUpdate1.UploadedComplete
'handler logic...
End Sub
If there is no WithEvents
qualifier, then the following works:
AddHandler AsyncFileUpload1.UploadedComplete, AddressOf AsyncFileUpload1_UploadedComplete
To remove the event handler, do the following:
RemoveHandler AsyncFileUpload1.UploadedComplete, AddressOf AsyncFileUpload1_UploadedComplete
Beware of the WithEvents/Handles
route as this can cause memory leaks. It is simply syntactic sugar and wires up an AddHandler behind the scenes. I add this because I've been burned before with it while learning VB (I had a C# background).