Creating dynamic controls with events on Web 2.0 in Xojo2024r3

I have run the desktop example with control sets. It works as expected.

I tried to create a web equivalent of this in new project.

I see the following error trying to compile the code

WebPage1.ControlCountPopup.SelectionChanged, line 20
The constructor of this class is protected, and can only be called from within this class
newLabel = New ButtonLabel

I see similar errors on each of the control sets used. Can some one help me get something like this working on web.

I don’t necessarily need controls sets, although that would be preferred. What I need is to be able to dynamically create controls that have added events/methods in them. The examples for dynamically created controls on web work as long as I am using the base control

lbl = new WebLabel

However, if I subclass this to Label1

lbl = new Label1

also gives me the above error. Again works fine on desktop

Can you share a sample project of what you tried and gives errors?
Zip your project and upload here.

ControlSet.zip (10.3 KB)

My guess is that the controlset is new in Web and is not working the same as Desktop.
You can file an Issue to see if they can match the behavior to Desktop.

I’ll do that. But first,

What about the line that says lbl = new Class1

Class1 is a subclass of WebLabel (it is NOT a control set)

It generates the same error.

For some reason, you need to add a public method called Constructor, with Super.Constructor in it.

I don’t think we can add a Method to the ContolSet, so the code that works on Desktop does not work on Web for this protected constructor.

Thank you. At least I can proceed. I can maintain my own array of created controls.

It complies and creates the control, but it does not respond the event.

The one labeled dynamic does not respond, the one labeled IDE (same class) does.
DynamicWEvent.zip (11 KB)

I’m sorry I can’t help. I don’t have much experience with dynamic controls.
If something is different than Desktop, please create an Issue with the Desktop and Web samples.
That way @Ricardo_Cruz can review and fix what is needed (Web and/or Documentation).

Issue: #77690