Back button complicates ASP shopping cart item removal

Discussion in 'ASP General' started by Penny, May 25, 2005.

  1. Penny

    Penny Guest

    Hi all,

    I've built an online shopping cart using ASP Classic(based on a 'WebThang'
    tutorial). The shop cart page (with table showing customers selected items
    and costs) has only 3 buttons/links.

    1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.

    2: Remove Item(one next to each item in cart): Clears the selected item from
    the session variable array redisplays the page.

    3: Checkout: Proceeds nicely to the pages that collect the customers
    details.

    My Problem:

    If the user clicks the 'Remove Item' link/button, the page efficiently
    redisplays with the selected item removed from the list. However, if the
    user then clicks either the 'Back to Shop' button or the browser Back button
    (intending to continue shopping), the cart page redisplays showing the
    removed item back in the list as it was before they removed it. Although the
    session variable array remains correctly unaltered it is very confusing to
    the user and will probably cause them to feel that their shopping list has
    been 'messed up' and is now invalid.

    I understand that the browser is just 'doing what it is told' but need to
    find a way to avoid this confusing behaviour.

    Any ideas,

    Regards

    Penny.
     
    Penny, May 25, 2005
    #1
    1. Advertising

  2. "Penny" <> wrote in message
    news:...
    > Hi all,
    >
    > I've built an online shopping cart using ASP Classic(based on a 'WebThang'
    > tutorial). The shop cart page (with table showing customers selected items
    > and costs) has only 3 buttons/links.
    >
    > 1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.
    >
    > 2: Remove Item(one next to each item in cart): Clears the selected item
    > from
    > the session variable array redisplays the page.
    >
    > 3: Checkout: Proceeds nicely to the pages that collect the customers
    > details.
    >
    > My Problem:
    >
    > If the user clicks the 'Remove Item' link/button, the page efficiently
    > redisplays with the selected item removed from the list. However, if the
    > user then clicks either the 'Back to Shop' button or the browser Back
    > button
    > (intending to continue shopping), the cart page redisplays showing the
    > removed item back in the list as it was before they removed it. Although
    > the
    > session variable array remains correctly unaltered it is very confusing to
    > the user and will probably cause them to feel that their shopping list has
    > been 'messed up' and is now invalid.
    >
    > I understand that the browser is just 'doing what it is told' but need to
    > find a way to avoid this confusing behaviour.


    If you use location.replace to navigate between pages, the old page gets
    replaced in the history stack with the new page, giving you somewhat of an
    opportunity to manage what's available to go back to.

    -Mark



    > Any ideas,
    >
    > Regards
    >
    > Penny.
    >
    >
     
    Mark J. McGinty, May 25, 2005
    #2
    1. Advertising

  3. Penny

    Penny Guest

    Hi Mark,

    Do you have any snippets of code I could see to get a perspective on how
    location.replace can be used?

    Regards

    Penny.


    "Mark J. McGinty" <> wrote in message
    news:...
    >
    > If you use location.replace to navigate between pages, the old page gets
    > replaced in the history stack with the new page, giving you somewhat of an
    > opportunity to manage what's available to go back to.
    >
    > -Mark
     
    Penny, May 25, 2005
    #3
  4. Penny

    Patrice Guest

    If you don't want the user be able to see previous pages (exactly as they
    were previously) you could likely prevent caching :
    http://support.microsoft.com/kb/234067/en-us

    Let us know if it works...

    Patrice

    --

    "Penny" <> a écrit dans le message de
    news:...
    > Hi all,
    >
    > I've built an online shopping cart using ASP Classic(based on a 'WebThang'
    > tutorial). The shop cart page (with table showing customers selected items
    > and costs) has only 3 buttons/links.
    >
    > 1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.
    >
    > 2: Remove Item(one next to each item in cart): Clears the selected item

    from
    > the session variable array redisplays the page.
    >
    > 3: Checkout: Proceeds nicely to the pages that collect the customers
    > details.
    >
    > My Problem:
    >
    > If the user clicks the 'Remove Item' link/button, the page efficiently
    > redisplays with the selected item removed from the list. However, if the
    > user then clicks either the 'Back to Shop' button or the browser Back

    button
    > (intending to continue shopping), the cart page redisplays showing the
    > removed item back in the list as it was before they removed it. Although

    the
    > session variable array remains correctly unaltered it is very confusing to
    > the user and will probably cause them to feel that their shopping list has
    > been 'messed up' and is now invalid.
    >
    > I understand that the browser is just 'doing what it is told' but need to
    > find a way to avoid this confusing behaviour.
    >
    > Any ideas,
    >
    > Regards
    >
    > Penny.
    >
    >
     
    Patrice, May 25, 2005
    #4
  5. Penny

    Jeff Cochran Guest

    On Wed, 25 May 2005 19:49:08 +0800, "Penny" <>
    wrote:

    >Do you have any snippets of code I could see to get a perspective on how
    >location.replace can be used?


    It's a client-side Javascript so you may want to ask in a Javascript
    group, but here's a reference page:

    http://www.klaban.torun.pl/help/jsref/location.htm

    Jeff


    >
    >"Mark J. McGinty" <> wrote in message
    >news:...
    >>
    >> If you use location.replace to navigate between pages, the old page gets
    >> replaced in the history stack with the new page, giving you somewhat of an
    >> opportunity to manage what's available to go back to.
    >>
    >> -Mark

    >
     
    Jeff Cochran, May 25, 2005
    #5
  6. Penny

    Jeff Cochran Guest

    On Wed, 25 May 2005 11:46:49 +0800, "Penny" <>
    wrote:

    >Hi all,
    >
    >I've built an online shopping cart using ASP Classic(based on a 'WebThang'
    >tutorial). The shop cart page (with table showing customers selected items
    >and costs) has only 3 buttons/links.
    >
    >1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.
    >
    >2: Remove Item(one next to each item in cart): Clears the selected item from
    >the session variable array redisplays the page.
    >
    >3: Checkout: Proceeds nicely to the pages that collect the customers
    >details.
    >
    >My Problem:
    >
    >If the user clicks the 'Remove Item' link/button, the page efficiently
    >redisplays with the selected item removed from the list. However, if the
    >user then clicks either the 'Back to Shop' button or the browser Back button
    >(intending to continue shopping), the cart page redisplays showing the
    >removed item back in the list as it was before they removed it. Although the
    >session variable array remains correctly unaltered it is very confusing to
    >the user and will probably cause them to feel that their shopping list has
    >been 'messed up' and is now invalid.
    >
    >I understand that the browser is just 'doing what it is told' but need to
    >find a way to avoid this confusing behaviour.


    I would think if you coded the shopping cart page to read the session
    variables to populate the fileds and prevented caching on the page you
    would see the result you want. Perhaps using a pragma:nocache header
    would do it, you can use a meta tag for this:

    <meta http-equiv="pragma" content="nocache">

    There are other ways to disable page caching as well.

    Jeff
     
    Jeff Cochran, May 25, 2005
    #6
  7. Penny

    Penny Guest

    Patrice,

    It works in that it prevents previously removed items from the cart being
    shown again but when expecting to be redirected back to the last 'shopping'
    page it usually says 'Warning: Page has Expired'.

    The suggested code:

    <% Response.CacheControl = "no-cache" %>
    <% Response.AddHeader "Pragma", "no-cache" %>
    <% Response.Expires = -1 %>

    Seems to prevent redirecting to whatever the previous page was. My catch is
    that I want to return to the 'shop' page that directed to the 'cart' page in
    the first place but not return to an old version of the 'cart' page itself.
     
    Penny, May 25, 2005
    #7
  8. Penny

    Penny Guest

    Thanks Jeff,

    I'll have a play with that and get back to you.
     
    Penny, May 25, 2005
    #8
  9. Penny

    Penny Guest

    Jeff,

    <meta http-equiv="pragma" content="nocache"> doesn't work either. It still
    allows the page to redirect to the previous version of itself.

    Penny.

    >
    > I would think if you coded the shopping cart page to read the session
    > variables to populate the fileds and prevented caching on the page you
    > would see the result you want. Perhaps using a pragma:nocache header
    > would do it, you can use a meta tag for this:
    >
    > <meta http-equiv="pragma" content="nocache">
    >
    > There are other ways to disable page caching as well.
    >
    > Jeff
     
    Penny, May 26, 2005
    #9
  10. Penny

    Adrienne Guest

    Gazing into my crystal ball I observed "Penny" <>
    writing in news::

    >
    >>
    >> I would think if you coded the shopping cart page to read the session
    >> variables to populate the fileds and prevented caching on the page you
    >> would see the result you want. Perhaps using a pragma:nocache header
    >> would do it, you can use a meta tag for this:
    >>
    >> <meta http-equiv="pragma" content="nocache">
    >>
    >> There are other ways to disable page caching as well.
    >>

    > Jeff,
    >
    ><meta http-equiv="pragma" content="nocache"> doesn't work either. It still
    > allows the page to redirect to the previous version of itself.
    >
    > Penny.



    IIRC the Meta element is controled by the browser and the browser can
    disregard it. AFAIK you have to do it server side, eg:
    Response.Expires = 60
    Response.Expiresabsolute = Now() - 1
    Response.AddHeader "pragma","no-cache"
    Response.AddHeader "cache-control","private"
    Response.CacheControl = "no-cache"

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, May 26, 2005
    #10
    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. Sparky Arbuckle

    Only First Shopping Cart Item Displays

    Sparky Arbuckle, Feb 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    307
    Sparky Arbuckle
    Feb 20, 2005
  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    cookieless asp.net shopping cart code/how to

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Aug 14, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    460
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=
    Aug 14, 2005
  3. alex sparsky
    Replies:
    3
    Views:
    471
    George
    Jan 5, 2006
  4. semut

    Shopping cart ASP.NET

    semut, May 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    456
    clintonG
    May 30, 2006
  5. JJ
    Replies:
    2
    Views:
    420
    Ken Cox [Microsoft MVP]
    Jul 31, 2006
Loading...

Share This Page