How to trigger actions in WebContainers to the calling Webpage?

Is there a common way to react on actions in a webcontainer depending which webpage calls the container?

My approach is to distinguish between the names of the calling webpage:

[code]Select Case self.parent.name

Case “webpage1”
webpage1.DoSomething()

case else
MsgBox "Ooops - don’t know the webpage: "_
+ self.parent.name

end select[/code]

I often add a Property into the Child WebContainer of the Parent’s type. In the Open event of the Parent, you set the Child’s property to ‘me’. This way I can access all the methods and controls of the parent from within the child.

Also remember that Parent might not be a WebPage. It could be a WebDialog or another WebContainer.

Thanks David. But this doesn’t work for me.

In the container “ctTest” I declare a public property “pparent” with the type webdialog. ctTest is embedded in the webdialog and instanciated as “ctTest1”. In the Open-Event of the webdialog I set:

ctTest1.pparent = me

In ctTest I call after a textfield ist changed:

pparent.doSomething()

When I try to debug XOJO tells me:

Type "Webdialog" has no member named "doSomething" pparent.doSomething()

Say your WebDialog is named ‘WDAccounts’.

‘pparent’ should not be of generic type ‘WebDialog’, but typed as ‘WDAccounts’. Then in the Open event of WDAccounts set:

ctTest1.pparent = self

Then all your code inside ctTest1 doesn’t just know that pparent is a WebDialog, it know exactly which WebDialog it is. If WDAccounts has a method called ‘doSomething()’ then inside ctTest1 you can call pparent.doSomething().

If it is a WebContainer inside another WebContainer it needs to be adjusted, but it works too.

Thanks David, this is working :slight_smile:

So the advantage to using “Select Case Self.Parent.Name” is, that I can use the dialog in different places of my project (dlg1, dlg2, dlg…) and don’t have to distinguish between the calling parent-dialogs in the embedded container.

This will work, if the parent is always the specific webdialog. Is there also a possibilty for a more common approach to cover what Greg said? “Also remember that Parent might not be a WebPage. It could be a WebDialog or another WebContainer.”