Adding instances of button or label at runtime

Hi, adding buttons at runtime works fine in desktop app… but I can not get it to be done in web version… why:

code in desktop: (in the action of a button already in the window)
Dim pb As PushButton
pb = New PushButton1
pb.caption=“Clone”
pb.Left=Me.Left+Me.Width+100
pb.top = me.top+ 100
pb.visible = TRUE

code in webpage: (in the action of a button already in the web-page)
Dim pb As WebButton
pb = New Button1
pb.caption=“Clone”
pb.Left=Me.Left+Me.Width+100
pb.top = me.top+ 100
pb.visible = TRUE

so for desktop this works very well, but for web, it does not… or what am I missing ?

The Control Set New method does not work in Xojo Web.

Use dynamic WebContainers instead.

Sorry, but i don’t understand… can I add these in the same way ? or where do I find a dynamic webContainer

http://documentation.xojo.com/index.php/WebContainer.EmbedWithin

Thanks I’ll try

Worked! Thanks.

But, what is best practice for numbering… using control set we had index. Now I added a property as integer, then when creating an instance I set this to a new higher number. and used that for reference later… Is that the best way ?

[quote=227452:@Helge Tjelta]Worked! Thanks.

But, what is best practice for numbering… using control set we had index. Now I added a property as integer, then when creating an instance I set this to a new higher number. and used that for reference later… Is that the best way ?[/quote]

Why not use an array property of WebContainers instead ? That way you keep a reference to all your dynamic WebContainers so you can close them if needed, and you have UBound and Index.

Good sugestion, I’ll give it a try.