How to pass a parameter between pages?

Discussion in 'ASP .Net' started by Spongebob, Jan 25, 2004.

  1. Spongebob

    Spongebob Guest

    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.NoCache), 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
     
    Spongebob, Jan 25, 2004
    #1
    1. Advertising

  2. (Spongebob) wrote in
    news::
    > 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
     
    Chad Z. Hower aka Kudzu, Jan 25, 2004
    #2
    1. Advertising

  3. Spongebob

    Hermit Dave Guest

    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" <> wrote in message
    news:Xns947B87A259934cpub@127.0.0.1...
    > (Spongebob) wrote in
    > news::
    >> 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
    >
     
    Hermit Dave, Jan 25, 2004
    #3
  4. "Hermit Dave" <> wrote in
    news::
    > 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
     
    Chad Z. Hower aka Kudzu, Jan 25, 2004
    #4
  5. Spongebob

    Hermit Dave Guest

    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" <> wrote in message
    news:Xns947BE026351A1cpub@127.0.0.1...
    > "Hermit Dave" <> wrote in
    > news::
    >> 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
    >
     
    Hermit Dave, Jan 25, 2004
    #5
  6. "Hermit Dave" <> wrote in
    news:OSFxd#:
    > 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
     
    Chad Z. Hower aka Kudzu, Jan 25, 2004
    #6
  7. Spongebob

    Hermit Dave Guest

    yeap but the page has to be within the same application right now
    http://weblogs.asp.net/pwilson/archive/2003/10/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" <> wrote in message
    news:Xns947BEEB337261cpub@127.0.0.1...
    > "Hermit Dave" <> wrote in
    > news:OSFxd#:
    >> 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
    >
     
    Hermit Dave, Jan 25, 2004
    #7
  8. Spongebob

    Spongebob Guest

    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 :=(
     
    Spongebob, Feb 11, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kairi Zikpin

    Re: Pass data between pages

    Kairi Zikpin, Jul 1, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    407
    Kairi Zikpin
    Jul 1, 2003
  2. blufox
    Replies:
    2
    Views:
    565
  3. Gonzalo Moreno

    Pass parameter from pages aspx

    Gonzalo Moreno, Dec 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    180
    Phil H
    Dec 26, 2006
  4. WeAreGoing!
    Replies:
    1
    Views:
    157
    Lasse Reichstein Nielsen
    Dec 1, 2003
  5. AzamSharp
    Replies:
    2
    Views:
    181
Loading...

Share This Page