How do I keep form variables?

Discussion in 'ASP .Net' started by Mark 123, Jan 24, 2005.

  1. Mark 123

    Mark 123 Guest

    Hi

    I have two forms on one ASPX order page. There are two submit buttons:

    1) "Calculate"
    2) "Order"

    The first form at the top of the page has the Product Name and Quantity as
    form fields. The calculate button works out the total order cost and puts it
    into a form field when the button is clicked and the page re-loaded (POST
    action)

    The second form has the customer order details; name, address, telephone
    etc.

    I have a MSAccess database to store all data, including the price and
    quantity. However, whilst the database has the name, address, telephone etc,
    the price and quantity are always blank. I am using the Request("Quantity")
    syntax for ASP. I have tried to store the value with Session("Quantity") but
    that still comes up blank. I don't want to use Cookies.

    Any suggestions?

    TIA
    Mark 123, Jan 24, 2005
    #1
    1. Advertising

  2. Here's a nice, simple way to pass values from one page to another:
    (VB.NET code)

    'Add data to the context object before transferring
    Context.Items("myParameter") = x
    Server.Transfer("WebForm2.aspx")

    Then, in WebForm2.aspx:

    'Grab data from the context property
    Dim x as Integer = CType(Context.Items("myParameter"),Integer)

    Of course there are a number of ways to pass values from one page to
    another, such as using the querystring, cookies, session,
    context, saving to a temporary table in the database between each page, etc.
    You'll have to decide which technique is best for your application.
    Here are several good articles on the subject to help you decide.
    http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

    http://www.aspalliance.com/kenc/passval.aspx

    http://www.dotnetbips.com/displayarticle.aspx?id=79

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Mark 123" <> wrote in message
    news:lG0Jd.10945$...
    > Hi
    >
    > I have two forms on one ASPX order page. There are two submit buttons:
    >
    > 1) "Calculate"
    > 2) "Order"
    >
    > The first form at the top of the page has the Product Name and Quantity as
    > form fields. The calculate button works out the total order cost and puts
    > it
    > into a form field when the button is clicked and the page re-loaded (POST
    > action)
    >
    > The second form has the customer order details; name, address, telephone
    > etc.
    >
    > I have a MSAccess database to store all data, including the price and
    > quantity. However, whilst the database has the name, address, telephone
    > etc,
    > the price and quantity are always blank. I am using the
    > Request("Quantity")
    > syntax for ASP. I have tried to store the value with Session("Quantity")
    > but
    > that still comes up blank. I don't want to use Cookies.
    >
    > Any suggestions?
    >
    > TIA
    >
    >
    >
    >
    >
    Steve C. Orr [MVP, MCSD], Jan 24, 2005
    #2
    1. Advertising

  3. Mark 123

    Mark B Guest

    Thanks. I wonder if that will work where instead of progressing on to a
    second webpage, the 'next' webpage is just a refresh caused by clicking the
    'Calculate' button which does a form POST.



    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:%...
    > Here's a nice, simple way to pass values from one page to another:
    > (VB.NET code)
    >
    > 'Add data to the context object before transferring
    > Context.Items("myParameter") = x
    > Server.Transfer("WebForm2.aspx")
    >
    > Then, in WebForm2.aspx:
    >
    > 'Grab data from the context property
    > Dim x as Integer = CType(Context.Items("myParameter"),Integer)
    >
    > Of course there are a number of ways to pass values from one page to
    > another, such as using the querystring, cookies, session,
    > context, saving to a temporary table in the database between each page,

    etc.
    > You'll have to decide which technique is best for your application.
    > Here are several good articles on the subject to help you decide.
    >

    http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx
    >
    > http://www.aspalliance.com/kenc/passval.aspx
    >
    > http://www.dotnetbips.com/displayarticle.aspx?id=79
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "Mark 123" <> wrote in message
    > news:lG0Jd.10945$...
    > > Hi
    > >
    > > I have two forms on one ASPX order page. There are two submit buttons:
    > >
    > > 1) "Calculate"
    > > 2) "Order"
    > >
    > > The first form at the top of the page has the Product Name and Quantity

    as
    > > form fields. The calculate button works out the total order cost and

    puts
    > > it
    > > into a form field when the button is clicked and the page re-loaded

    (POST
    > > action)
    > >
    > > The second form has the customer order details; name, address, telephone
    > > etc.
    > >
    > > I have a MSAccess database to store all data, including the price and
    > > quantity. However, whilst the database has the name, address, telephone
    > > etc,
    > > the price and quantity are always blank. I am using the
    > > Request("Quantity")
    > > syntax for ASP. I have tried to store the value with Session("Quantity")
    > > but
    > > that still comes up blank. I don't want to use Cookies.
    > >
    > > Any suggestions?
    > >
    > > TIA
    > >
    > >
    > >
    > >
    > >

    >
    >
    Mark B, Jan 24, 2005
    #3
    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. Galina
    Replies:
    0
    Views:
    383
    Galina
    Dec 15, 2003
  2. =?Utf-8?B?QUNhdW50ZXI=?=

    keep losing session variables

    =?Utf-8?B?QUNhdW50ZXI=?=, Jan 18, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,372
    Saravana
    Jan 18, 2005
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    1
    Views:
    379
  4. Replies:
    9
    Views:
    914
  5. hisan
    Replies:
    1
    Views:
    1,289
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page