By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

How to pass a parameter between pages?

P: n/a
Hello, I have a question about how to pass information between pages in

ASP.NET. There are 2 pages : page1.aspx, page2.aspx.
On page1 user clicks the record. Then, I need to show the detailed info

about that record in page2. How to pass the ID of record? Should I use

querystring or cookies or session variable?

The problem is:
1. I don't want to use query string at all :^(

2. There is no need to create the cookie or session variable for a

certain time, I only want to pass the int number from page1 to page2. :^(

3. It seems to me that the best way to solve that is to pass number via

page header. I use this sintax: :^(

in page1:
Response.AppendHeader("recordID","123");
Response.Redirect("page2.aspx");

in page2 on page load event:
Label1.Text=Request.Headers["recordID"].ToString(); //oh... :=(

But that doesn't work. May be wrong caching parameters? I've tried to set

Response.Cache.SetCacheability(HttpCacheability.No Cache), but that didn't

work too.

4. I think other suggested methods are too resource-expensive, why don't

use headers?

Oh, could somebody please explain me how to solve the situation?

Thanks a lot for Your attention and reading my message :^)

Andriy
Nov 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
ee****@list.ru (Spongebob) wrote in
news:c3*************************@posting.google.co m:
The problem is:
1. I don't want to use query string at all :^(
No, that would be bad. You need to minimize the data you pass about.
3. It seems to me that the best way to solve that is to pass number via

page header. I use this sintax: :^(

in page1:
Response.AppendHeader("recordID","123");
Response.Redirect("page2.aspx");


Pass it in the URL. Something like:
Response.Redirect("page2.aspx?RecordID=123");

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #2

P: n/a
lol... well the reason why i ignored the post was that he did not want to
use query string.
he didnot want to use session...
well mate.. wait for asp.net 2.0.. you have cross page posting when you can
post from one aspx page to another without resorting to query string or
session
btw.. session isnt so bad... you can always set it to nothing after you are
done reading it.

--
Regards,
HD
Once a Geek.... Always a Geek
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
ee****@list.ru (Spongebob) wrote in
news:c3*************************@posting.google.co m:
The problem is:
1. I don't want to use query string at all :^(


No, that would be bad. You need to minimize the data you pass about.
3. It seems to me that the best way to solve that is to pass number via

page header. I use this sintax: :^(

in page1:
Response.AppendHeader("recordID","123");
Response.Redirect("page2.aspx");


Pass it in the URL. Something like:
Response.Redirect("page2.aspx?RecordID=123");

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #3

P: n/a
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in
news:Ou**************@TK2MSFTNGP12.phx.gbl:
lol... well the reason why i ignored the post was that he did not want
to use query string.
Sorry, when I read query I thought SQL. I didnt understand that he meant the
GET / URL string.
well mate.. wait for asp.net 2.0.. you have cross page posting when you
can post from one aspx page to another without resorting to query string
or session


How does this work exactly in asp.net 2?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #4

P: n/a
well in 2.0 you have a new feature which allows you to post to a different
aspx page.
you have something called previouspage (within the page that received the
post) which is used to partially instantiate the aspx class (that caused the
post to the second aspx class or page however you put it).
once it is partially instantiated.. you can read the variables within the
instance.

--
Regards,
HD
Once a Geek.... Always a Geek
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in
news:Ou**************@TK2MSFTNGP12.phx.gbl:
lol... well the reason why i ignored the post was that he did not want
to use query string.


Sorry, when I read query I thought SQL. I didnt understand that he meant
the
GET / URL string.
well mate.. wait for asp.net 2.0.. you have cross page posting when you
can post from one aspx page to another without resorting to query string
or session


How does this work exactly in asp.net 2?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #5

P: n/a
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in
news:OS**************@tk2msftngp13.phx.gbl:
well in 2.0 you have a new feature which allows you to post to a
different aspx page.
you have something called previouspage (within the page that received
the post) which is used to partially instantiate the aspx class (that
caused the post to the second aspx class or page however you put it).
once it is partially instantiated.. you can read the variables within
the instance.


So if I understand you it works this way:

On post an event in the new page is fired.

From this event I can access the variables from the last page.

But I have to read all the variables - ie it elimiates postback type things
correct?

So its very simlilar to what we have now, you are just defining where to go
before hand, and the event is fired on that page instead.

Is this correct?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #6

P: n/a
yeap but the page has to be within the same application right now
http://weblogs.asp.net/pwilson/archi.../29/34597.aspx

you create a partial instance of posting class in the in the page that
received the post..
yes but right now you dont have a way of posting it to anothe page... unless
you put them in a query string and do a response.redirect. or put them in
session so that the other page you call can read it..

--
Regards,
HD
Once a Geek.... Always a Geek
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in
news:OS**************@tk2msftngp13.phx.gbl:
well in 2.0 you have a new feature which allows you to post to a
different aspx page.
you have something called previouspage (within the page that received
the post) which is used to partially instantiate the aspx class (that
caused the post to the second aspx class or page however you put it).
once it is partially instantiated.. you can read the variables within
the instance.


So if I understand you it works this way:

On post an event in the new page is fired.

From this event I can access the variables from the last page.

But I have to read all the variables - ie it elimiates postback type
things
correct?

So its very simlilar to what we have now, you are just defining where to
go
before hand, and the event is fired on that page instead.

Is this correct?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #7

P: n/a
asp.net 2 must be cool :~)

The reason why I didn't want to use session is also that it expires
very soon on my system :=(
Nov 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.