Sessions variables in vb.net

G

Guest

Hello,

Where can I declare my application and session variables? I havn't found the
way to do this in VB except by declaring them "Public shared" in a class with
no constructor. Where is this done in most VB.net projects?

thank you for helping
 
J

John Saunders

Cedric FABIOUX said:
Hello,

Where can I declare my application and session variables? I havn't found
the
way to do this in VB except by declaring them "Public shared" in a class
with
no constructor. Where is this done in most VB.net projects?

Application and Session variables are not variables. You do not declare them
at all.

"Application" and "Session" are collection objects. "Application" is an
instance of the HttpApplicationState class, and "Session" is an instance of
the HttpSessionState class. Both classes have a property called Item, which
is an indexed property. This property can be indexed by the name of the
"variable":

Application.Item("varname") or
Session.Item("varname")

These can be abbreviated as

Application("varname") or
Session("varname")

You can set your "variable" with

Application("varname") = value or
Session("varname") = value


John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top