Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 13th, 2004, 01:42 AM
Registered User
 
Join Date: Oct 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem w/ session var being incremented on reload

Hello,
I was running the "session.aspx" example from "Beginning ASP.NET using VB.NET", Ch 10, and came across some strange/unexpected behavior. If the basket has a non-zero item count and the page is then reloaded, the item count gets automatically incremented. It seems as if the AddClick handler is being fired on reload. It does not do this if the item count is zero. Can anyone tell me why is this happening and how I can stop it from doing this? The something similar happens with Exercise 4 (another shopping cart page). Any help would be appreciated, as I'm really stumped on this.

Thanks in advance,
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
Reload page Tooltip not work - Reload xslt file? ismailc XSLT 10 January 22nd, 2008 10:03 AM
reload/refresh problem notChavez PHP How-To 23 January 16th, 2007 06:21 AM
Problem in Reload a GridView using Timer udhayav .NET Framework 2.0 0 December 16th, 2006 07:16 AM
the counter is not incremented harag XSLT 2 November 10th, 2003 11:54 AM





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