If we create and show several instances of the same webdialog from within a loop, only the last one is displayed. All previous webdialog are created in the DOM, but set to ‘display: none;’.
Even changing the visibility property in the shown or open event of the webdialog doesn’t display them.
Thats an example code:
Webpage with one button:
Sub Action() Handles Action
Var f() As Integer
f = Array (1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
Var i As Integer = 0
For Each e As Integer In f
Var a As New WebDialog1
a.Button1.Caption = e.ToString
a.Show
i = i + 1
Next
Me.Caption = i.ToString
End Sub
When running this, only the last webdialog is shown, the others are created and sent to browser, but invisible:
I solve this by using Javascript in the open-event. But is that really the only solution???
Sub Shown() Handles Shown
Var js As String = "document.getElementById('" + Self.ControlID + "').style.display = 'block';"
Self.ExecuteJavaScript(js)
End Sub
I may be wrong here, but it seems that you are overwriting a with each successive iteration. Only the last iteration is there at the end. You would need something like a(e) instead of a to see them all. With every reference to a changed accordingly.
Hm no, not really. a becomes created freshly with every loop. So I don’t overwrite it, I create new instances every single time. And when you .show a webdialog, it is sent to the client and is displayed there, until it is closed by .close.
Also: the dialogs are present in the browser, they are just not visible/displayed.
web is asynchronous. contrary to desktop.
you can’t display a dialog and wait for the user input like you do in a desktop app
you must fill forms, or deal with each dialog in an asynchronous way.
The dialogs are super flexible and display vast informations depending on the context. We have a use case, where the user has to go through a list of operations and decisions. Dialogs are just the most simple way to display that to the user.
I just want to know, if thats wanted behavior or if its one of the never-fixed bugs of web framework 1, where we need to find hacks or workarounds.
With the dialog being declared inside the loop, as soon as each iteration of the loop ends, it’s going to get destroyed. You’ll need to store them in an array somewhere if you want them to stick around.
If I make all the Dialogs visible with the Javascript above. I can still Communicate to the server, for example when I click on button within the web dialog. Also self is still available, I can call self.close, and then the web dialog gets closed in the frontend and gets destroyed in the server (I hope it gets destroyed, and that doesn’t just throw the close event. otherwise this would be a massive memory leak).
So either the strange behavior is that the dialogs are created in the frontend but not removed there after the loop ends, or that the dialogs aren’t visible.