querystring and going back in browser

T

tony collier

Hi all

I have a shopping cart which I have had to use querystrings to
add/remove items rather than a form. for example, i have a page with a
list of items and next to each one is a button which when clicked refers
to the same page with a different querystring item=12, item=33 etc.

My pageload routine then checks for any query strings and if it finds an
item value, adds this to the respective session variable.

My problem is that if a client adds an item, goes to checkout or any
other page for that matter, then decides to go back in the browser to
the itemlist page, the item gets added again because the querystring is
reloaded along with the page.

Any ideas how I can make sure that items are only added/removed when the
referrer is the same page?

thanks.
 
G

Guest

If the event is on the same page, then you could hold an array of items in the page, and when the user clicks the 'add' button, it just adds an item to the array (no query strings involved). When the page is loaded, check to see whether the page is posted back. If it is not posted back, make sure the array is cleared so the items aren't added twice.
 
R

Rocky Moore

If you have a button, why not user a server control like linkbutton or a
button and grab the onClick in your code behind. Then when they click it,
you could have a field somewhere on the screen that you would update saying
it has been added.

Since it is not passed in a querystring as you have been processing it, you
would only need to process in the OnClick which is only triggered if it is a
postback event.
 
T

tony collier

If you have a button, why not user a server control like linkbutton or
a button and grab the onClick in your code behind. Then when they
click it, you could have a field somewhere on the screen that you
would update saying it has been added.

Since it is not passed in a querystring as you have been processing
it, you would only need to process in the OnClick which is only
triggered if it is a postback event.

thanks guys for the suggestion. I still have a problem though in that I
can't put a form on my page because half of it is screenscraped and for
some reason adding a form to this won't display the whole page. So how can
I add a button without embedding it in a form?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top