View Single Post
Old July 14th, 2003, 02:11 AM
wireblock wireblock is offline
Authorized User
Join Date: Jul 2003
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP .NET using C# session problem !!


   I got the following code:

<%@ Page language="c#"%>
<script Language="c#" runat="server">
  void EmptyClick(object sender, EventArgs e)
    Session["BasketCount"] = 0;
  void AddClick(object sender, EventArgs e)
    if (Session["BasketCount"] != null)
      int i = (int)Session["BasketCount"];
      Session["BasketCount"] = (object)i;
    } else {
      Session["BasketCount"] = 1;

    <form id="BasketForm" method="post" runat="server">
      <asp:Button id="Empty" OnClick="EmptyClick" runat="server" Text="Empty"/>
      <br />
      <asp:Button id="Add" OnClick="AddClick" runat="server" Text="Add"/>
      <br />
      Basket items : <%=Session["BasketCount"]%>
      <br />

which I got it from Wrox Beginning ASP .NET using C#.
The book mension that if I refresh this page, the count of the no. of items in the basket will remain the same. But it won't ! When I refresh the page, the no. keep increasing ! How come? Pls help, thanks !