WebControl.Open vs Shown

I know that the docs say to use WebControl.Shown instead of WebControl.Open when affecting a UI object and how it displays. But let’s say I have a couple WebLabels that show the user the page’s Title (“MyGreatApp”) and its version (“v1.1”). In the IDE, I see those two WebLabels on any given WebPage layout as “Title” and “Version” respectively. This way I can see them and move them if needed, in the IDE.

Well, if I use the WebControl.Shown event for each of them, to assign them their values, the user will see “Title” and “Version” before they see the actual values for them. If I use WebControl.Open, this is not the case. Is there some undesirable side effect to assigning such WebControls their values in the WebControl’s Open event (or the WebPage’s Open event), versus the Shown event?

I think it only matters if you’re trying to do something in Open before the control actually exists aka shown. For instance, if you were showing a google map and wanted to add points, that might need to be performed in Shown since the control might not actually exist yet.

Changing the Label Text should be safe in Open since that’s a ‘simple’ Xojo Property.

Another option would be to make the controls not visible in Open or before Open and then make your changes in Shown along with making them visible again.

[quote=358946:@Hal Gumbert]Changing the Label Text should be safe in Open since that’s a ‘simple’ Xojo Property.
[/quote]

I would not bet on that. If there are many label, it is quite possible one is not complete and crash.

You can use a server-side timer (the same as Desktop) to fill your labels just before shown. The catch is, since the DOM formation is dependent on bandwidth, on a really slow connection, for instance a 56k modem in the middle of nowhere, or a 3G connection lost in the bush, the timer may yet fire too early.

You can also leave title and Label.Text as “” in the IDE.

[quote=359008:@Michel Bujardet]I would not bet on that. If there are many label, it is quite possible one is not complete and crash.

You can use a server-side timer (the same as Desktop) to fill your labels just before shown. The catch is, since the DOM formation is dependent on bandwidth, on a really slow connection, for instance a 56k modem in the middle of nowhere, or a 3G connection lost in the bush, the timer may yet fire too early.

You can also leave title and Label.Text as “” in the IDE.[/quote]
I ended up setting those labels in the method that embeds their containers instead of in their Shown events. So those labels are assigned values just before their container is embedded. I realize I didn’t mention that I’m dealing with full-layout embedded containers the user moves through.

After reading Hal’s reply, I tried just making those labels Not Visible in the IDE and then, in their Shown events, assigning them values and making them Visible. That method causes those labels to disappear and reappear as the user changes containers. But my method above makes them appear as never changing when containers change. Setting the label Text as “” in the IDE also has the same side effect as Hal’s method, of course.

That’s a good point since shown runs everytime it’s shown…