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


Re: Global Variable question/Clarification 
Modified By osmosis311  on 5/20/2009 12:55:11 AM)

 Hi Ori,

So first, if you have the time to explain, I'm still a little confused as to what a "static" variable really means.  Second, what does "Control class-member variables" refer to?

And are you saying that public variables/properties of an instantiated class are automatically in the Context?  Because right now I created a wrapper class as was suggested previously, with properties that use VWGContext.Current("varname") as part of the Get/Set for those class variables.  Do I not need to do that?

Thanks!

 
New Post 5/22/2009 6:33 PM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi Danny,

Static means Global which means that all instances of your application will stare that same memory slot for that variable storage.

Control class-member variables, as I understand it, are just all local variables within your MainForm (and all controls that are kept there) that need to be saved to store the state of your application server-side.

I think it would be best now that you describe to us what kind of variables or data you are talking about when you find the need to store those variables in the context scope? What kind of data is it that you want to save in those variables, and for what purpose ... meaning where will it be used etc.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 5/22/2009 6:52 PM
  osmosis311
383 posts
3rd Level Poster


Re: Global Variable question/Clarification 

 Hi Palli,

The only thing I am using it for is to store user-specific variables, such as UserID, UserName, UserLocation, etc.  These are things that I cannot store or lookup in a database, and I need to access these variables from different Forms within the application as the user goes to them.

For example, when the user logs in, I am storing their UserID (and other variables), and then I use that UserID throughout the application to pull information from the database that is related to them, based on their UserID.

Right now I am using your suggestion.  I created a Public class called GlobalVariables, with Get and Set storing the variable in VWGContext.Current("variable_name").  In each Form, I use Private GC as new GlobalVariables.....Dim UserID as string=GC.UserID

I have not tested with multiple users yet to ensure that they are indeed getting their own information.

So, what do you think? :-)

Thanks!!

 
New Post 5/22/2009 7:01 PM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi Danny,

Very similar to what I told you I was doing myself except that I don't use that "convenient" wrapper class, just go directly into the VWGContext.Current(). But, same result.

So how can I say it's anything else than ok :-)

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 1/22/2010 9:57 PM
  derekmhart@yahoo.com
685 posts
1st Level Poster


Re: Global Variable question/Clarification 
Modified By derekmhart@yahoo.com  on 1/23/2010 1:30:29 AM)

I have a class library that I wish to use global variable in. I don't have the same scenario where I am clearly loading a main form, to load a variable that stores the current session's variables. So perhaps I should just use VWGContext. So if I put this static variable in a class:

    Public Shared CustomObjectName As String = ""

The way to make that into a variable that only works within the current context is by creating this. Even though the property is shared, the way it is used is only in the current context. Am I on track?

    Public Shared Property CustomObjectName() As String
        Get
            Return VWGContext.Current("CustomObjectName")
        End Get
        Set(ByVal Value As String)
            VWGContext.Current("CustomObjectName") = Value
        End Set
    End Property
 
Now how would I do a similar thing, but just use a simpler instance of a variable, but not have to create a class each time, in a class library? Would I put a class into a variable in a Sub New() in the class?

 
Previous Previous
 
Next Next
  Forum  General Visual ...  Let's Chat Abou...  Global Variable question/Clarification
CompanionKit 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