Session Arrays

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select from?

Could I please have a sample of how this is done. The obvious syntax that I
am trying doesn't work. There are SA's in VB, but I am not seeing anything
for C#.

Thank you!

-Bahman
 
Not sure if you are talking about the Session object. If so, in C#, we use
square brackets ([]) to access the session collection as in
Session["mykey"].

HTH

Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select from?

Could I please have a sample of how this is done. The obvious syntax that I
am trying doesn't work. There are SA's in VB, but I am not seeing anything
for C#.

Thank you!

-Bahman
 
Perhaps if you showed us what syntax you were using that doesn't work, we
could be of more help.

I'm not sure what you mean by "session arrays"

In ASP.Net you have a session which you can access in c# such as:

Session["SomeUserId"] = 1;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
Karl,

In VB, you can say

session("array") (1) = "1"
session("array") (2) = "2"

In other words, the session object can be assigned a type other than the
basic types of numbers and strings, in this case an array.

I wonder if that can be done in c#. Obviously, I wouldn't know how to define
it since we don't explicity define session objects, I would think.

The syntax wouldn't need to be the same. For example, if I could create an
array, assign it to some kind of session object, create another array, and
assing the session object back to the other array, that would work too. I
wouldn't need the session variable itself to work like an array. But it would
be nice.

Also, all I am trying to do is use the array on a different page. If I can
make the array somehow persistent in some other way, that would be very ok as
well.

-Bahman

Karl Seguin said:
Perhaps if you showed us what syntax you were using that doesn't work, we
could be of more help.

I'm not sure what you mean by "session arrays"

In ASP.Net you have a session which you can access in c# such as:

Session["SomeUserId"] = 1;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Bahman said:
Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select from?

Could I please have a sample of how this is done. The obvious syntax that
I
am trying doesn't work. There are SA's in VB, but I am not seeing anything
for C#.

Thank you!

-Bahman
 
The only reason VB let's you do that, is because you have Option Strict Off.
Turn it on, and you will get a compile time error.

Always use option strict On, when you are using VB.

In either case (VB with option strict on, or C#), you need to case
session("array") to an array of whatever type is appropriate, and only then
can you access a particular item in the array.

Bahman said:
Karl,

In VB, you can say

session("array") (1) = "1"
session("array") (2) = "2"

In other words, the session object can be assigned a type other than the
basic types of numbers and strings, in this case an array.

I wonder if that can be done in c#. Obviously, I wouldn't know how to
define
it since we don't explicity define session objects, I would think.

The syntax wouldn't need to be the same. For example, if I could create an
array, assign it to some kind of session object, create another array, and
assing the session object back to the other array, that would work too. I
wouldn't need the session variable itself to work like an array. But it
would
be nice.

Also, all I am trying to do is use the array on a different page. If I can
make the array somehow persistent in some other way, that would be very ok
as
well.

-Bahman

Karl Seguin said:
Perhaps if you showed us what syntax you were using that doesn't work, we
could be of more help.

I'm not sure what you mean by "session arrays"

In ASP.Net you have a session which you can access in c# such as:

Session["SomeUserId"] = 1;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Bahman said:
Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select
from?

Could I please have a sample of how this is done. The obvious syntax
that
I
am trying doesn't work. There are SA's in VB, but I am not seeing
anything
for C#.

Thank you!

-Bahman
 
Marina,

This is outstanding.

I only have one question for you.

How do I 'case' a session variable to become an array in c#?

Could you please point me to a page or site with samples or definitions?

Thank you very much for your help!

-Bahman

Marina said:
The only reason VB let's you do that, is because you have Option Strict Off.
Turn it on, and you will get a compile time error.

Always use option strict On, when you are using VB.

In either case (VB with option strict on, or C#), you need to case
session("array") to an array of whatever type is appropriate, and only then
can you access a particular item in the array.

Bahman said:
Karl,

In VB, you can say

session("array") (1) = "1"
session("array") (2) = "2"

In other words, the session object can be assigned a type other than the
basic types of numbers and strings, in this case an array.

I wonder if that can be done in c#. Obviously, I wouldn't know how to
define
it since we don't explicity define session objects, I would think.

The syntax wouldn't need to be the same. For example, if I could create an
array, assign it to some kind of session object, create another array, and
assing the session object back to the other array, that would work too. I
wouldn't need the session variable itself to work like an array. But it
would
be nice.

Also, all I am trying to do is use the array on a different page. If I can
make the array somehow persistent in some other way, that would be very ok
as
well.

-Bahman

Karl Seguin said:
Perhaps if you showed us what syntax you were using that doesn't work, we
could be of more help.

I'm not sure what you mean by "session arrays"

In ASP.Net you have a session which you can access in c# such as:

Session["SomeUserId"] = 1;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select
from?

Could I please have a sample of how this is done. The obvious syntax
that
I
am trying doesn't work. There are SA's in VB, but I am not seeing
anything
for C#.

Thank you!

-Bahman
 
string[] cough = (string[])Session["SomeArrayKey"];

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


Bahman said:
Marina,

This is outstanding.

I only have one question for you.

How do I 'case' a session variable to become an array in c#?

Could you please point me to a page or site with samples or definitions?

Thank you very much for your help!

-Bahman

Marina said:
The only reason VB let's you do that, is because you have Option Strict
Off.
Turn it on, and you will get a compile time error.

Always use option strict On, when you are using VB.

In either case (VB with option strict on, or C#), you need to case
session("array") to an array of whatever type is appropriate, and only
then
can you access a particular item in the array.

Bahman said:
Karl,

In VB, you can say

session("array") (1) = "1"
session("array") (2) = "2"

In other words, the session object can be assigned a type other than
the
basic types of numbers and strings, in this case an array.

I wonder if that can be done in c#. Obviously, I wouldn't know how to
define
it since we don't explicity define session objects, I would think.

The syntax wouldn't need to be the same. For example, if I could create
an
array, assign it to some kind of session object, create another array,
and
assing the session object back to the other array, that would work too.
I
wouldn't need the session variable itself to work like an array. But it
would
be nice.

Also, all I am trying to do is use the array on a different page. If I
can
make the array somehow persistent in some other way, that would be very
ok
as
well.

-Bahman

:

Perhaps if you showed us what syntax you were using that doesn't work,
we
could be of more help.

I'm not sure what you mean by "session arrays"

In ASP.Net you have a session which you can access in c# such as:

Session["SomeUserId"] = 1;

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Hello!

I have a simple question.

Do we have session arrays that we can reference, assign, or select
from?

Could I please have a sample of how this is done. The obvious
syntax
that
I
am trying doesn't work. There are SA's in VB, but I am not seeing
anything
for C#.

Thank you!

-Bahman
 

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

Back
Top