Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.0
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2004, 03:24 PM
Registered User
 
Join Date: Oct 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 10: Problem with shopping cart example code

Hello everyone,
I was running the session.aspx example in ch 10, and came across some strange/unexpected behavior. If the basket has a non-zero count of items and the page is then reloaded, the item count gets automatically incremented. It seems as if the AddClick handler is being fired on reload. Can anyone tell me why is this happening and how I can stop it from doing this? The same thing happens with Exercise 4 (another shopping cart page). Any help would be appreciated.

Thanks and Regards,
Storm

Relevent Code:
Code:
<%@ Page language="VB"%>
<SCRIPT language="vb" runat="server">

Sub EmptyClick(Sender as System.Object, E As System.EventArgs)
    Session("BasketCount") = 0
End Sub


Sub AddClick(Sender as System.Object, E As System.EventArgs)
        Session("BasketCount") += 1
End Sub

</SCRIPT>

<HTML>
<HEAD>
    <LINK href="../General.css" rel="stylesheet">
    <TITLE>Session Example</TITLE>
</HEAD>
<BODY>
<FORM id="BasketForm" method="post" runat="server">
    <ASP:button id="btnEmpty" text="Empty" onClick="EmptyClick" runat="server" />
    <BR/>
    <ASP:button id="btnAdd" text="Add" onClick="AddClick" runat="server" />
    <BR/>
    Basket Items: <%=Session("BasketCount") %>
    <BR/>
</FORM>
</BODY>
</HTML>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shopping Cart Code incomplete dipeshedesign BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 3 September 23rd, 2009 12:06 PM
Ch.13 Builing a Shopping Cart seannie BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 February 7th, 2007 10:11 AM
Altering Shopping Cart Code for Paypal flashcash5 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 April 19th, 2005 09:58 PM
CH. 14 cart.php code problem shawnrberg BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 June 21st, 2004 05:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.