Search code examples
c#vb.netcode-translation

How to add an event handler in VB.NET?


This code is part of AjaxControlToolkitSampleSite. To be exact, it is in the AsyncFileUpload control:

 AsyncFileUpload1.UploadedComplete += new EventHandler<AsyncFileUploadEventArgs>(AsyncFileUpload1_UploadedComplete);

How can I translate this to VB.NET?


Solution

  • Here you go:

    AddHandler AsyncFileUpload1.UploadedComplete, AddressOf AsyncFileUpload1_UploadedComplete
    

    Alternatively, within your code, you can select the AsyncFileUpload1 control from the left-hand dropdown list (just above the code) and then select the UploadComplete event from the right-hand dropdown list.

    This will automatically create an event handler with the correct signature using the VB Handles declaration.