How do you use AddHandler on a WebDialog

I have a WebDialog open that contains a popup. One of the options in the popup is “Other…”. If the user selects “Other…”, I need to ask them what they want and add it to the popup selected.

So i am opening another WebDialog (sheet) to ask for the desired entry. How do I get the response.

First thing I did was create a WebDialog called Request and put the following in the popup SelectionChanged event…

[code] If pu_title.Text=“Other…” Then
Dim req As New mw_Request
req.lbl_Request.text = “What is your title”
req.txtFld_Response.text = “”

End If[/code]

I then created a method RequestDialogDismissed(d As WebDialog) to handle the response…

pu_title.ListIndex = 0

To call the handler I added a handler…

If pu_title.Text="Other..." Then Dim req As New mw_Request req.Title = "Title" req.lbl_Request.text = "What is your title" req.txtFld_Response.text = "" AddHandler req.Close RequestDialogDismissed(req) req.Show End If

That does not work as I get an error saying “This method doesn’t return a value” with “AddHandler req.Close” highlighted.

The Docs say that if the event returns a parameter then the handler method must return a parameter of the same type. I don’t see where the Close event returns a parameter. If so what is it?

Is there a better way to get this done?



Addhandler expects a Delegate that points to the method you want to have invoked, but your code is invoking the method directly (and the compiler is trying to use the non-existent return value as the delegate, hence the error.) Use the AddressOf (or WeakAddressOf) methods to acquire a delegate for a specific method:

AddHandler req.Close, AddressOf RequestDialogDismissed

Andrew Thanks. That did it. After seeing your sample code I realized I had 2 mistakes. I had tried AddressOf early on and was not succsessful. The problem was that I was passing a paramater… RequestDialogDismissed(req). Now I understand what the Docs and the error was trying to tell me. The handler method must have parameters that match exactly what the event being handled whould have passed.

In this case the Close event does not have any parameters and so me putting one in when intializing the handler threw the build errror. That is exactly what the error was saying that the Close event does not have any paremeters… don’t pass any to your handler, dummy.

The WebDialog being passed to the handler is a given and need not be mentioned in the AddHandler call.

Thanks again