473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Can't set session variables

Hello!

I'm quite new to ASP.Net and trying to send a variable from one page to
another.

Om my first page, Index.htm page I have a link as:
<a href="Default.aspx?MyID=7">Def 7</a>

On Default.aspx I have following code in the load event:
Label1.Text = "MyID=" + Convert.ToString( Page.Session["MyID"]);

I really think it would work, but I only get the text MyID=.
Is the <a> tag not setting a session variable?

Any ideas
/Magnus
Nov 18 '05 #1
2 1720
It is not. Why should it? You can get the parameter with
Request.Params["MyID"].

Eliyahu

"Magnus Blomberg" <ma*************@skanska.se> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello!

I'm quite new to ASP.Net and trying to send a variable from one page to
another.

Om my first page, Index.htm page I have a link as:
<a href="Default.aspx?MyID=7">Def 7</a>

On Default.aspx I have following code in the load event:
Label1.Text = "MyID=" + Convert.ToString( Page.Session["MyID"]);

I really think it would work, but I only get the text MyID=.
Is the <a> tag not setting a session variable?

Any ideas
/Magnus

Nov 18 '05 #2
Hi,

what you're doing here is with QueryString, not session objects. In that
case, your second line would look like: -

Label1.Text = "MyID=" + Convert.ToString( Request.QueryString["MyID"]);

Or else, if you want to use ASP.NET session object, set the session object
in the first page as follows :-

if (!PostBack)
{
Page.Session["MyID"] = 7;
}

then call it from the second page :-

Label1.Text = "MyID=" + Convert.ToString( Page.Session["MyID"]);

Regards
Joyjit

"Magnus Blomberg" <ma*************@skanska.se> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello!

I'm quite new to ASP.Net and trying to send a variable from one page to
another.

Om my first page, Index.htm page I have a link as:
<a href="Default.aspx?MyID=7">Def 7</a>

On Default.aspx I have following code in the load event:
Label1.Text = "MyID=" + Convert.ToString( Page.Session["MyID"]);

I really think it would work, but I only get the text MyID=.
Is the <a> tag not setting a session variable?

Any ideas
/Magnus

Nov 18 '05 #3

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

Similar topics

3
by: Jessica Loriena | last post by:
I'm trying to write a simple "register form / validate and store in database / show welcome screen" application with ASP.Net. With conventional ASP, I used Session variables and it went something...
6
by: Nedu N | last post by:
Hi, I am trying to design a Home page for my applicatiion in which i want show the links for for some itms... I tried to put the following <td> <font face="Arial, Helvetica, sans-serif" ...
1
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
5
by: Oleg Ogurok | last post by:
Hi all, Is there a way to read other people's session variables? I understand it makes sense that session state is on per-user basis, but still... Is there a way to get a collection of all...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
3
by: Lee Moore | last post by:
I have some user controls defined that represent a common header and footer for a particular site. the footer contains links with querystring parameters based on session variables. The problem is,...
1
by: Larry Neylon | last post by:
Hi, I'm working on a VBScript application on IIS6 and I'm looking for some advice about the best way of replacing or improving session variable usage. The application is in a secure extranet...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
6
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.