Forum  General Visual ...  Let's Chat Abou...  Global Variable question/Clarification
Previous Previous
 
Next Next
New Post 5/17/2009 3:28 PM
  osmosis311
383 posts
3rd Level Poster


Re: Global Variable question/Clarification 

 Hi Palli,

THANK YOU! As always :-)

Just a couple more clarifying questions...

If I want a variable to be per-user, and also local to the form, I can simply declare a Private Variable right below the class declaration?  So it will be global for all the methods of the Form, but no other form will be able to access it (and other users will not be able to see each other's variables)?

Is there a limit to the amount of data/variables I can store in the session object?  Can I store as many as I want/need?

 

Thanks!

 
New Post 5/17/2009 3:45 PM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi Danny,

You are welcome... glad I can help.

Yes, you are correct about that. If you declare your variables private (just don't make them static) within your form class, they are local to every instance of your form's class. Each user opening your form will have a new instance of it, and there fore a new copy of those variables. And they will be accessible to all methods within your form and other users will have their own copy of them.

If you on the other hand open the same form in a second tab of your FF browser, that is the same instance of your form being opened.

Theoretically, you can store anything you want to, as much as you want to within the sesson object, but that is usually not thought to be a best practice, as you will be consuming memory on your server. If you need to store large datastuctures, you might consider storing them to a database with an Id or something that you allocate within your form. Or you can use some other method you see fit.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 5/18/2009 11:36 AM
  derekmhart@yahoo.com
685 posts
1st Level Poster


Re: Global Variable question/Clarification 

In reference to this answer below, I am not seeing how to get to a variable using the code. If I try this:
VWGContext.Current.MainForm.    I don't seem to be able to see any variables after MainForm. How to I get to the variables?

Hi,

Ryan's example shows you how you would set variables within your mainform to store this information for you, and then you would need to be calling the GetContextVariable function, knowing some control within that form, like when you're calling it from a button handler or something like that.

If that is not acceptable, that function should be easily converted to use VWGContext.Current.MainForm to get to the mainform and provide the same functionality as Ryan is suggesting.

Palli



 

 
New Post 5/18/2009 12:01 PM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi,

VWGContext.Current.MainForm is just a generic formtype, so to get to your controls/properties/fields, you can use type casting, like in VB.NET if your MainForms's type is Form1, you would use CType(VWGContext.Current.MainForm,Form1).Button1 etc.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 5/19/2009 5:53 AM
  ori.cohen
4383 posts
1st Level Poster




Re: Global Variable question/Clarification 
Modified By ori.cohen  on 5/19/2009 7:56:35 AM)

Hello Danny,

To complete Palli's answer, all non-static Control class-member variables that are used in a VWG application are automatically stored in the Context scope of the application.
They are stored as part of the server-side state of the application per-context, and so they must reside in the Context scope.

Regards,

Ori Cohen
Support Manager, the Visual WebGui team

 
Previous Previous
 
Next Next
  Forum  General Visual ...  Let's Chat Abou...  Global Variable question/Clarification
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS