can not retrieve context items

B

bruce barker

Context items only live for the life of the page requiest. they are
generally used to pass data between modules during a page request.

-- bruce (sqlwork.com)
 
R

Rea Peleg

Hi eb
I am adding in webForm1.aspx some item to the context items collection
in order to extract it in the next aspx page:

In webForm1.aspx - c# code behind - i do:
---------------------------------------------------------------
Context.Item.add("variableName",variableVaue);
//test that add item succeeded:
string test = (string)Context.Item["variableName"];
if (test.Equals(variableVaue))
{
Server.Transfer(webForm2.aspx,true);
}
----------------------------------------------------------------
Then in webForm2.aspx :

string strVar = (string)Context.Item["variableName"];
Here strVar is null...
--------------------------------------------------------------
If i do the same procedure with session object instead - it works.
What am i missing??

Thanks for your attention
Rea
 
R

Rea Peleg

Interesting...
But I have seen a few examples of this nature in the internet.
This is where i got the idea from the first place.
What do you meen than by 'passing variables between modules'?
If these are code modules i can pass variables to them without the context
object at all..
What is your preffered method to passing variables between web forms?
Are there reasons not to do it with the good old session object?
I know one can use Server.Transfer("nextWebForm.aspx",true) to pass one
the request.querystring from current form to the next one, but have read
that
a bug in asp.NET mite cause an error here in some cases(?)
Thanks again for your answer
Rea




bruce barker said:
Context items only live for the life of the page requiest. they are
generally used to pass data between modules during a page request.

-- bruce (sqlwork.com)

Rea Peleg said:
Hi eb
I am adding in webForm1.aspx some item to the context items collection
in order to extract it in the next aspx page:

In webForm1.aspx - c# code behind - i do:
---------------------------------------------------------------
Context.Item.add("variableName",variableVaue);
//test that add item succeeded:
string test = (string)Context.Item["variableName"];
if (test.Equals(variableVaue))
{
Server.Transfer(webForm2.aspx,true);
}
----------------------------------------------------------------
Then in webForm2.aspx :

string strVar = (string)Context.Item["variableName"];
Here strVar is null...
--------------------------------------------------------------
If i do the same procedure with session object instead - it works.
What am i missing??

Thanks for your attention
Rea
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top