I'm developing an ASP Application using VB and are having a bit of trouble with my variables. On my first page im recieving input from my user and I need to know how i can use that on the page that the user gets redirected to
I had hoped it would be as simple as declaring a variable on the opening pages public and then referencing it but the other pages can't see it.
Any one have any ideas. Im still quite new to ASP and VB.net, still stuck in the good old VB6 days.
Regards
Dan

Newbie: How do I declare a Global or Public Variable?
prof.Scuba
If this is a web service.... it's important to rmember that each request consitutes a new instantiation and with it new data arrays. For in memory persistence, declare variables as shared and they will persist as long as the webservice is in memory.
I just wanted to emphasize What David Jeavons said because he's correct but I'm not sure that he hilighted why the empahsis on shared variables. Shared member variables are ceated once across instantiations and maintain their data.
kthiagar
Hi
I am assuming that this is an ASP.NET application as you mentioned ASP and VB.NET. If so, then you have a few options of passing data between pages. If it is just a simple value and you don't mind who sees the value then you could pass it using the QueryString when you redirect to the next page:
Response.Redirect("YourPage.aspx YourValueKey=" & YourVariableOrControlValue).
To read the QueryString value back on your next page you use:
Request.QueryString("YourValueKey")
Alternatively, you can use the Session to store the value. This is more appropriate if you want to persist an object or you don't want anybody to see the value on the QueryString. To add something to a session variable you can do:
Session.Add("YourKeyName", YourVariableOrControlValue)
To read a value from the session use:
Session("YourKeyName")
Another option would be to create a class that contained shared properties allowing you to read and write values. For example:
Public Class Class1
Private Shared _yourValue As String
Public Shared Property YourValue() As String
Get
Return _yourValue
End Get
Set(ByVal Value As String)
_yourValue = Value
End Set
End Property
End Class
and then when you want to set a value you use:
Class1.YourValue = "YourStringValue"
and to read from any page use:
Response.Write(Class1.YourValue)
HTH
st3ph3n
If I understand that caveat - that shared variables (or public variables in Modules) are global to the application (like Application variables) - how do we create variables whose values are globally accessible to a user (i.e. a single instance) of a VB.NET application, but not globally modifiable by anyone else using that application
Let me state that more plainly: we need a global variable, USERID, which is read/write uniquely by each user.
In my (limited VB) experience, Session variables require the context of a web page i.e. System.Web.SessionState.HttpSessionState, or something similar, and aren't generally available inside a stand-alone class or module.
The cleanest, but by no means transparent, solution I have so far is to instantiate a class, call it GLOB, in which all variables I may need globally reside. Subsequent calls to methods or classes are passed a reference to GLOB so they, too, know the state of the outside world.
Does someone know a better way
Chris