Addhandler for web button

Hello all,

I have a web Container_AppointView wich contain a webButton.
In my container, I have a RaiseEvent on the Action Event of the container.

RaiseEvent ed_Container_X_Open

I have an event definition in the container

ed_Container_X_Open (no parameters, no return type)
On the Page_Client I am embedding the container,
In the proprety of the page, I defined

Public Property Container_AppointView1 as Container_AppointView
In a method,

Container_AppointView1 = New Container_AppointView Container_AppointView1.EmbedWithin(Self,20,105,580,700) AddHandler Container_AppointView1.ed_Container_X_Open, AddressOf m_ContainerContainer_X_Open
Now, the debugger is returning

[quote]Page_Client.m_ContainerAppointViewOpen, line 9
Type mismatch error. Expected delegate Delegate( Container_AppointView.Container_AppointView ), but got delegate Delegate( )
AddHandler Container_AppointView1.ed_Container_X_Open, AddressOf m_ContainerContainer_X_Open
[/quote]
It worked well yesterday morning but I change something in the code (wich I don’t remember, of course, and don’t have a previous copy…)

Since I used this code somewhere else and it is working, I am wondering what I am missing…

You probably forgot webButton as sender in the parameters of your method.

Merci Michel,
If I put

Sender As Container_AppointView

the debugger is returning

Page_Client.m_ContainerAppointViewOpen, line 9 Type mismatch error. Expected delegate Delegate( Container_AppointView.Container_AppointView ), but got delegate Delegate( ) AddHandler Container_AppointView1.ed_ShimamuraOpen, AddressOf m_ContainerShimamuraOpen
and also getting an error on another Container on the same page that is working well.

Looks like a conflict…

Compiler messages are often obtuse, but this one is outright confusing unless you already know what it means.

It’s telling you that the handler method (AKA the Delegate created with AddHandler) doesn’t match the signature of the event it’s assigned to. Event handler methods expect to receive the object that’s raising the event as their first parameter:

Sub m_ContainerContainer_X_Open(Sender As Container_AppointView)

Ordinarily the IDE will hide this detail from you, but you have to be aware of it when assigning event handlers with AddHandler.

Thanks Andrew,
I will take a look at it tomorrow morning.