Array of controls in Web

I’ve been trying to use a solution presented for desktop in a web app but nothing is visible. Did I miss something or does this not work in a web app?

My Code:

dim labelsArray as webLabel(-1)

dim top as integer = 0
for i as integer = 0 to 4
labelsArray.append new lblTest
next i

for i as integer = 0 to 4
top = top + labelsArray(i).height + 10
labelsArray(i).left = 20
labelsArray(i).top = top
labelsArray(i).enabled = true
labelsArray(i).text = "Test Label " + str(i)
labelsArray(i).visible = true
next i

You cannot create new members that way. To add controls dynamically to a web page, use Webcontainers.embedwithin.

Thanks . . .

My app relies heavily on containers.

This is yet another attempt to create a drag-and-drop between web list boxes.

You need to find a way to do it in Javascript, not Xojo; or you’re just hurting the user.

You need to find a way to do it in Javascript, not Xojo; or you’re just hurting the user.

Why’s that?

Because of the way Xojo Web currently works. All of your Xojo code is compiled server side. Every action the user performs that interacts with your Xojo code has to go all the way to the server, be processed, and go all the way back to the user. This delay is variable and cannot be relied on in any manner.

Any kind of interface action, such as drag & drop, needs to be implemented in the browser.

Thanks . . .

Have you looked at the web drag and drop examples?

I have Greg . . . but they won’t work between list boxes.

You might be able to get this to work in Web Framework 1.0 by embedding WebContainers into the WebListbox. However, this will break in Web Framework 2.0. But if you need it now, it works great!

You can find a demo at the bottom of this thread that I created with help from @Brock Nash. This should let you add a control that can accept drags to a WebContainer that you embed in a WebListbox: https://forum.xojo.com/46100-what-can-i-embed-within-a-weblistbox/11#p422157

If you like the idea of embedding WebContainers in WebListboxes, please add this to your top feedback case which is at 56th: <https://xojo.com/issue/54683>

Hal . . . . What do you mean it will break in Web Framework 2.0 ?

My web apps use a lot of containers

This sounds like a dumb question but . . .

I’m testing dragging and dropping containers but I need to identify the container I’ve dragged and get data from it.

I’ve tried using controlWithID but it doesn’t work.

I’ve tried setting properties when the mousedown event happens but it won’t allow drag and drop.

ideas?

Your best bet would be to create the web equivalent of the desktop listbox, with webcontainers. Contrary to the webListbox, the desktop listbox does not smooth scroll. Rows never move, only data. That makes creating it’s web equivalent relatively easy. And it would enable dragging and dropping between grids.

The embedding of Containers in Listboxes uses javascript to move the containers. That specific javascript won’t work in Web FW 2.0.

But in Web FW 2.0 Containers will be able to ‘float left’ essentially creating a list of containers if placed in a surrounding container.

Thanks guys. I’m working on it.

How do I identify the container that has been dragged so I can get information from its properties?

So I’ve tried a rawdatadrop but it doesn’t show the property values from the dragged container . . . nor does it retain the property values

WebControl.DropObject
The obj parameter is the element that was dragged.

Thanks Maurizio . . . But I can’t get any information from the object’s properties.

One try: msgbox obj.sender.skillname (skillname is a property in the dragged container

Error: Type “WebControl” has no member named “skillname”

Second try: (after putting the dragged container’s control ID in the label for the dropped control (labelContainer.Label1.text = obj.sender.controlID))

msgbox controlwithID(labelContainer.Label1.text).skillname

Error: Type “WebControl” has no member named “skillname”

Third try: (after putting the dragged container’s control ID in the label for the dropped control (labelContainer.Label1.text = obj.sender.controlID))

msgbox controlwithID(labelContainer.Label1.text).Label1.text

Error: Type “WebControl” has no member named “Label1”

So I’m still stuck on how to get data from properties or the contents of the dragged container.

Thanks for your help

The Sender property is a WebControl that you must check with the IsA operator and refer using cast.
As an example if your dragged container type is myDraggableContainer:

If obj.Sender IsA myDraggableContainer Then dim TheDraggedContainer as myDraggableContainer = myDraggableContainer(obj.Sender) // Now you can refer to any public property or method of the dragged container TheDraggedContainer.skillname... End If

Look at the IsA operator for examples on type Casting.