[SOLVED] Best practice for sharing variables/objects across windows/pages

Answered
0
0

Hi!

Is this the best practice?

I cannot declare the windows in a module file because it will be accessible by other sessions (attached file).

Thanks,
Ulisses.

Attachment
  • You must to post comments
Best Answer
0
0

If you meant another tab for “windows/pages”. Otherwise, objects in the same sessions are already available to all windows and pages. You can find then in Application.OpenForms and OpenPages.

You can always save a reference in Application.Session.

And there is the Application.FindComponent methods that can find any control in any window or page at any level in the session.

 

https://wisej.com/docs/2.0/html/M_Wisej_Web_Application_FindComponent.htm

  • Ulisses
    Perfect, Luca! I’m using “OpenForms” now! Eg: MsgBox(CType(Application.OpenForms(“Window1”), Window1).TextBox1.Text) Thank you very much!
  • You must to post comments
0
0

Hi Ulisses,

There are a few ways to do that.  The way you have is fine.  Application.Session is a dynamically allocated Key/Dictionary collection.

Another way is to add a public property to the the new window and assign a value to that when instantiating it in the first window.  For example:

dim win2 as new Window2()

win2.SomePublicProperty = 5

win2.ShowDialog()
It depends what you’re trying to do!

Best regards,

Levie

  • Ulisses
    Thanks, Levie!
  • You must to post comments
0
0

Another tab is another session. You can share statics across sessions but you need  to handle the thread synchronization like in any multi threading system.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.