473,468 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

querystring and going back in browser

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.
Nov 18 '05 #1
3 1165
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.
Nov 18 '05 #2
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.

--
Rocky Moore
www.HintsAndTips.com - Share your tips with the world!
~~~~~~~~~ Developer Tips Welcome! ~~~~~~~~~

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@194.117.133 .134...
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.

Nov 18 '05 #3
"Rocky Moore" <gR*********@hintsandtips.com> wrote in
news:uN**************@TK2MSFTNGP12.phx.gbl:
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?

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Deepiceman | last post by:
Hi all, I am new to asp so bear with me. I want to write a page which will load a default page for me with some links and all. lets say someone clicks on the link, which not only points to the...
4
by: Raterus | last post by:
Howdy, Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to...
7
by: PJ6 | last post by:
I thought this was going to be simple. I want to take an HttpRequest and add an item to the QueryString. First I tried to add it directly, but I got a "Collection is read-only." error. So I...
6
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.