How do I maintain state between pages

Discussion in 'ASP General' started by Terri, Dec 9, 2003.

  1. Terri

    Terri Guest

    Hi All,

    I'd like to build a series of pages with next and back buttons that a user
    could enter data in. I'd like the data to be maintained if for example the
    user goes from page1 to page2 and then back to page1.

    I believe I could create hidden form fields on the pages and then post the
    forms data back and forth until my user gets to the last page when all the
    variables are submitted to a database.

    Is this an acceptable way to do this? If there are other ways what are the
    pros and cons?

    What about if the user uses the browsers next and back buttons? Will the
    results be different if they use next and back buttons that are created on
    my pages?

    Is there a better newsgroup where I could post this question??

    Thanks for any help.
    Terri, Dec 9, 2003
    #1
    1. Advertising

  2. Terri

    Stretch Guest

    "Terri" <> wrote in message
    news:br5khc$9ff$...
    > I believe I could create hidden form fields on the pages and then post the
    > forms data back and forth until my user gets to the last page when all the
    > variables are submitted to a database.
    >
    > Is this an acceptable way to do this? If there are other ways what are the
    > pros and cons?


    Good article on this topic:

    http://support.microsoft.com/?kbid=175167

    HTH-J
    Stretch, Dec 10, 2003
    #2
    1. Advertising

  3. HI there!
    I believe you can use session as:
    session("XXX") = VALUEX

    so now you can use you pages:
    response.write session("XXX")
    or attribute to something:
    varJ = session("XXX")

    bye.
    VILMAR
    BRAZIL
    "Terri" <> escreveu na mensagem
    news:br5khc$9ff$...
    > Hi All,
    >
    > I'd like to build a series of pages with next and back buttons that a

    user
    > could enter data in. I'd like the data to be maintained if for example the
    > user goes from page1 to page2 and then back to page1.
    >
    > I believe I could create hidden form fields on the pages and then post the
    > forms data back and forth until my user gets to the last page when all the
    > variables are submitted to a database.
    >
    > Is this an acceptable way to do this? If there are other ways what are the
    > pros and cons?
    >
    > What about if the user uses the browsers next and back buttons? Will the
    > results be different if they use next and back buttons that are created on
    > my pages?
    >
    > Is there a better newsgroup where I could post this question??
    >
    > Thanks for any help.
    >
    >
    >
    news.microsoft.com, Dec 10, 2003
    #3
  4. Terri

    Chris Barber Guest

    To be a little more concise (using the .Contents() method of the Session
    object implicitly is not a good idea):

    Session.Contents("NAME") = "YourValue"

    To output this session variable to the page from ASP use:

    This is the value of the session variable '<%=Session.Contents("NAME")%>'.

    or (I find this easier to use):

    <%
    Dim pstrOutput
    pstrOutput = Session.Contents("NAME")
    %>
    This is the value of the session variable '<%=pstrOutput%>'.

    or:

    <%
    Dim pstrOutput
    pstrOutput = Session.Contents("NAME")
    Response.Write "This is the value of the session variable '" & pstrOutput &
    "."
    %>

    Depends on what you want to do of course.

    You can also use client-side persistence passing querystrings around (and
    indeed, querystrings will also work server-side of course).

    Chris.

    "news.microsoft.com" <> wrote in message
    news:...
    HI there!
    I believe you can use session as:
    session("XXX") = VALUEX

    so now you can use you pages:
    response.write session("XXX")
    or attribute to something:
    varJ = session("XXX")

    bye.
    VILMAR
    BRAZIL
    "Terri" <> escreveu na mensagem
    news:br5khc$9ff$...
    > Hi All,
    >
    > I'd like to build a series of pages with next and back buttons that a

    user
    > could enter data in. I'd like the data to be maintained if for example the
    > user goes from page1 to page2 and then back to page1.
    >
    > I believe I could create hidden form fields on the pages and then post the
    > forms data back and forth until my user gets to the last page when all the
    > variables are submitted to a database.
    >
    > Is this an acceptable way to do this? If there are other ways what are the
    > pros and cons?
    >
    > What about if the user uses the browsers next and back buttons? Will the
    > results be different if they use next and back buttons that are created on
    > my pages?
    >
    > Is there a better newsgroup where I could post this question??
    >
    > Thanks for any help.
    >
    >
    >
    Chris Barber, Dec 10, 2003
    #4
    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. twahl
    Replies:
    2
    Views:
    618
    Tian Min Huang
    Jun 30, 2003
  2. Edwin Knoppert

    Maintain Treeview's expand states between pages

    Edwin Knoppert, Nov 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    595
    Edwin Knoppert
    Nov 7, 2005
  3. Replies:
    0
    Views:
    776
  4. VisionSet
    Replies:
    3
    Views:
    505
    VisionSet
    Jun 27, 2006
  5. Evan M.

    Maintain div display between pages

    Evan M., Mar 26, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    444
    Thomas Hansen
    Mar 26, 2007
Loading...

Share This Page