Hi Roland.
The biggest problem is that you’re reaching inside of your container and dialog to attach handlers to their internal controls, this is a big no-no in the world of object orientated programming, the container or dialog should be treated as a “black box”. Instead, you should only use the properties and events that the container and dialog expose.
Define an event definition on your container…
Event TextChanged(value As String)
… and then raise that event from the control inside the container…
Sub TextChanged()
RaiseEvent TextChanged(me.Text)
End Sub
When you create an instance of the container you then use AddHandler
on the exposed custom event…
Sub Shown()
dim container as new TextChangedContainer
container.EmbedWithin(me, me.Width - container.Width - 20, 20, container.Width, container.Height)
AddHandler container.TextChanged, AddressOf me.ReplaceOutput
End Sub
In the above example, the Shown
event for a WebPage
embeds a container and redirects its TextChanged
custom event to the page’s ReplaceOutput
method.
The same thing goes for WebDialogs, define an event definition that you raise from inside it, then handle the event in just the same way…
Sub Action()
dim dialog as new TextChangedDialog
dialog.Show
AddHandler dialog.TextChanged, AddressOf self.ReplaceOutput
End Sub
In the above example a WebButton
on the same page’s Action
event opens a new dialog and redirects the TextChanged
custom event to the page’s ReplaceOutput
method.
I’ve uploaded an example project that shows how to do this kind of thing.
https://dl.dropboxusercontent.com/u/6199282/AddHandlerWebDialogTest.zip
Hope that helps.