473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dummy question: How to retrieve Session state Variable from another Page?

Hi, Gurus,
I have two web forms frm1 and frm2. In frm1, I wrote session("StudentID")=
textbox1.text in a button click event. And then, Response.redirect("...frm2")
In frm2, Page_load event, I tried both response.write session("StudentID") and
textbox2.text=session("studentID"), none of them showing me what I got from frm1.
I don't know why??
My web.config reads:
.....................

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
........................

Please help!!!
Thank you
Nov 17 '05 #1
5 1576
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote

TextBox1.Text = DirectCast(Session("StudentID"))


Correction :
TextBox1.Text = DirectCast(Session("StudentID"), String)

Nov 17 '05 #2
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message news:<uT**************@TK2MSFTNGP09.phx.gbl>...
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote

TextBox1.Text = DirectCast(Session("StudentID"))


Correction :
TextBox1.Text = DirectCast(Session("StudentID"), String)


Carl,
Thank you very much for you reply.
But I tried, still doesn't work.
Here is what I did:

Page1: button1 click event.
Session("StudentID")="12345"
Response.write session("Student")

It even works withoout DIRECTCAST on the same page.

IF I do:
Page1:
Session("StudentID")="12345"
Response.Redirect("http://Testweb/frmPage2.aspx")

Page2:
Page_load-----response.write(directcast(session("StudentID"),str ing))
or textbox1.text=directcast(session("StudentID"),stri ng))
(----textbox1 is on page2----)
No error pops up but it does not show the 12345 either in the textbox
or on the left top side of the screen(I suppose this place is for
response.write)

Is this because thw way I used response.redirect?

Thank you
Nov 17 '05 #3
Carl, After I post last message, I tested it from a test machine by
opening the link and the page, it works!!!!!
Do you have any idea why I can see it working in .NET Development even
though I re-built the solution?

Thank you,
Tuxedo

"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message news:<uT**************@TK2MSFTNGP09.phx.gbl>...
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote

TextBox1.Text = DirectCast(Session("StudentID"))


Correction :
TextBox1.Text = DirectCast(Session("StudentID"), String)

Nov 17 '05 #4
"tuxedo" <tu*********@yahoo.com> wrote
Carl, After I post last message, I tested it from a test machine by
opening the link and the page, it works!!!!!

Tuxedo,
Cool. I'm glad you got it working on at least one machine... ;-)

Do you have any idea why I can see it working in .NET Development even
though I re-built the solution?


ASP.NET Session requires that you have an IIS Application (not just a virtual directory)
with a global.asax file in the root. Plus your Web browser must be cookie enabled
to accept a Session cookie, otherwise you'll need to use Session-less cookies via
the web.config's "sessionState" tag.

Anytime you save changes to global.asax., web.config, machine.config,
you'll restart your IIS Application. Make sure your anti-virus software
is not "touching" these files.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com


Nov 17 '05 #5
"tuxedo" <tu*********@yahoo.com> wrote
Carl, After I post last message, I tested it from a test machine by
opening the link and the page, it works!!!!!

Tuxedo,
Cool. I'm glad you got it working on at least one machine... ;-)

Do you have any idea why I can see it working in .NET Development even
though I re-built the solution?


ASP.NET Session requires that you have an IIS Application (not just a virtual directory)
with a global.asax file in the root. Plus your Web browser must be cookie enabled
to accept a Session cookie, otherwise you'll need to use Session-less cookies via
the web.config's "sessionState" tag.

Anytime you save changes to global.asax., web.config, machine.config,
you'll restart your IIS Application. Make sure your anti-virus software
is not "touching" these files.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com


Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
5
by: Pross | last post by:
I've got an ASP.NET application and I need some information on every page like the user's name as well as a collection listing which sections of the application the user has access to. I could...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
5
by: melinda | last post by:
Ok, sorry if this is dumb ?, but I'm extremely new to ASP.net. I've used PHP and am now trying to figure out the best way (or any way) to do this in ASP.net: I have a page where the user enters...
1
by: CK | last post by:
We recently upgraded a 1.1 app to 2.0. We are experiencing a strange bug that happens randomly. When a user is authenticated a string variable is added to the session. During debugging I put a...
4
chumlyumly
by: chumlyumly | last post by:
Hi - I'm working with PHP5 MySQL Mac OSX I've developed two pages where a user can input his/her info, which goes to a MySQL database. The first page is supposed to pass the newly created...
6
by: DNB | last post by:
I would like to know what you guys think is the best way to access data: Asp.Net session vs. Database Queries. In our application we are using asp.net tree view to display hierarchical data and...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.