How to reference Element of Session Page

Hi,
in my WebApp I’ve some modules and a TCP Client element inside a module.
If I get a TCP data then I would like to fill a listbox inside a webPage. But if I want to do anything with like WebPage1.listbox1… I always get a nil handle error. I understand the problem of WebPage and Session but my question is:
How can I get a reference to a specific control element of a webpage inside a session from a module?
Thank you.

[quote=481503:@Markus Neubauer]Hi,
in my WebApp I’ve some modules and a TCP Client element inside a module.
If I get a TCP data then I would like to fill a listbox inside a webPage. But if I want to do anything with like WebPage1.listbox1… I always get a nil handle error. I understand the problem of WebPage and Session but my question is:
How can I get a reference to a specific control element of a webpage inside a session from a module?
Thank you.[/quote]
So the problem is that the events of TCPSocket fire on the main thread outside of the context of a particular Session. What you need to do is store a reference to the session and then create a new instance of WebSessionContext when you need to access controls again.

You must be sure the requested page exists.
WebApplication.SessionCount
WebApplication.SessionAtIndex
WebSession.PageCount
WebSession.PageAtIndex
And when you find the page you must cast the returned “generic” webpage to the application page containing the listbox.

In any case something in a module that know what is contained in a page is a very tight coupling design.

[quote=481511:@Maurizio Rossi]You must be sure the requested page exists.
WebApplication.SessionCount
WebApplication.SessionAtIndex
WebSession.PageCount
WebSession.PageAtIndex
And when you find the page you must cast the returned “generic” webpage to the application page containing the listbox.

In any case something in a module that know what is contained in a page is a very tight coupling design.[/quote]
I’m currently trying out to get the control-element.
Do you have a better Idea for me how to receive commands from a socket at display it at control-elements?

Thank you, but I have currently no Idea how to do that. I’m totally new in Web App … so I need to learn a lot about it :slight_smile:
The thing is that I want to keep all incomming stuff organized in Moduls for a better overview.

GOT IT!
THANK YOU GUYS!! @Greg O’Lone and @Maurizio Rossi

[quote=481561:@Markus Neubauer]GOT IT!
THANK YOU GUYS!! @Greg O’Lone and @Maurizio Rossi[/quote]
Keep in mind that if you have more than one user logged in, the code you posted will send the info to the person who has been logged in the longest.