473,387 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

session state

Hey guys need some help on session state.

I'm trying to create an ASP.NET page to add items to it. W.G. if your out
there I could still use some help!

I'm not quite sure how to get it to work.

Page loads
User selects a value from a drop down list
uses a button to add item into a variable
user can then either add another item from the drop down list or clicks
another button to give them a total.

W.G. gave me a pointer to use a session state but I can't seem to get it to
work.

Here is what I have so far:

'Business logic constants

Const MEDIUM_BASE_PRICE As Double = 8.99

Const LARGE_BASE_PRICE As Double = 10.99

Const GIGANTIC_BASE_PRICE As Double = 12.99

Const TOPPING_PRICE As Double = 0.99

Const STANDARD_VIDEO_PRICE As Double = 1.95

Const NEW_RELEASE_VIDEO_PRICE As Double = 2.95

Const DELIVERY_FEE As Double = 2.0

Const TAX_RATE As Double = 0.065

Const COUPON_DISCOUNT As Double = 0.1 '(10 Percent)

Const FREE_DELIVERY_AMOUNT As Double = 20

'HTML constants

Const HTML_LEFT_ALIGN As String = "<p align=""left""> "

Const HTML_RIGHT_ALIGN As String = "<p align=""right""> "

Const HTML_INDENT As String = "&nbsp &nbsp &nbsp &nbsp "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim liNone, liMedium, liLarge, liGigantic As ListItem

'On first showing, fill ListBox, setExpDate and set Discount description

If Not IsPostBack Then

ddlPizzaSize.Items.Clear()

liNone = New ListItem

liNone.Text = "None"

liNone.Value = "None"

liMedium = New ListItem

liMedium.Text = "Medium (8"") -- " & FormatCurrency(MEDIUM_BASE_PRICE)

liMedium.Value = "Medium"

liLarge = New ListItem

liLarge.Text = "Large (10"")-- " & FormatCurrency(LARGE_BASE_PRICE)

liLarge.Value = "Large"

liGigantic = New ListItem

liGigantic.Text = "Gigantic (12"") -- " &
FormatCurrency(GIGANTIC_BASE_PRICE)

liGigantic.Value = "Gigantic"

ddlPizzaSize.Items.Add(liNone)

ddlPizzaSize.Items.Add(liMedium)

ddlPizzaSize.Items.Add(liLarge)

ddlPizzaSize.Items.Add(liGigantic)

ddlPizzaSize.SelectedIndex = 0

lblExpDate.Text = HTML_RIGHT_ALIGN & "Offer valid through " & _

FormatDateTime(Today().AddDays(7))

lblDiscountDesc.Text = FormatPercent(COUPON_DISCOUNT, 0) & " discount:"

Else

Session("mPizza") = 0

Session("lPizza") = 0

Session("gPizza") = 0

End If

End Sub

Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOrder.Click

Select Case ddlPizzaSize.SelectedItem.Value

Case "None" : Session("mPizza") = Session("mPizza") + 0

Case "Medium" : Session("mPizza") = Session("mPizza") + 1

Case "Large" : Session("lPizza") = Session("lPizza") + 1

Case "Gigantic" : Session("gPizza") = Session("gPizza") + 1

End Select

End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click

txtTest.Text = Session("mPizza") + Session("lPizza") + Session("gPizza")

End Sub

Nov 22 '05 #1
1 1151
Mike,

If I understand what you're trying to do, you shouldn't be resetting the
session variables every time you post back. If you comment out the lines:
Session("mPizza") = 0

Session("lPizza") = 0

Session("gPizza") = 0

it should work (although I'd be more likely to move them to the True block
of the if statement so that they're properly initialized).

Jeff

"Mike" wrote:
Hey guys need some help on session state.

I'm trying to create an ASP.NET page to add items to it. W.G. if your out
there I could still use some help!

I'm not quite sure how to get it to work.

Page loads
User selects a value from a drop down list
uses a button to add item into a variable
user can then either add another item from the drop down list or clicks
another button to give them a total.

W.G. gave me a pointer to use a session state but I can't seem to get it to
work.

Here is what I have so far:

'Business logic constants

Const MEDIUM_BASE_PRICE As Double = 8.99

Const LARGE_BASE_PRICE As Double = 10.99

Const GIGANTIC_BASE_PRICE As Double = 12.99

Const TOPPING_PRICE As Double = 0.99

Const STANDARD_VIDEO_PRICE As Double = 1.95

Const NEW_RELEASE_VIDEO_PRICE As Double = 2.95

Const DELIVERY_FEE As Double = 2.0

Const TAX_RATE As Double = 0.065

Const COUPON_DISCOUNT As Double = 0.1 '(10 Percent)

Const FREE_DELIVERY_AMOUNT As Double = 20

'HTML constants

Const HTML_LEFT_ALIGN As String = "<p align=""left""> "

Const HTML_RIGHT_ALIGN As String = "<p align=""right""> "

Const HTML_INDENT As String = " "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim liNone, liMedium, liLarge, liGigantic As ListItem

'On first showing, fill ListBox, setExpDate and set Discount description

If Not IsPostBack Then

ddlPizzaSize.Items.Clear()

liNone = New ListItem

liNone.Text = "None"

liNone.Value = "None"

liMedium = New ListItem

liMedium.Text = "Medium (8"") -- " & FormatCurrency(MEDIUM_BASE_PRICE)

liMedium.Value = "Medium"

liLarge = New ListItem

liLarge.Text = "Large (10"")-- " & FormatCurrency(LARGE_BASE_PRICE)

liLarge.Value = "Large"

liGigantic = New ListItem

liGigantic.Text = "Gigantic (12"") -- " &
FormatCurrency(GIGANTIC_BASE_PRICE)

liGigantic.Value = "Gigantic"

ddlPizzaSize.Items.Add(liNone)

ddlPizzaSize.Items.Add(liMedium)

ddlPizzaSize.Items.Add(liLarge)

ddlPizzaSize.Items.Add(liGigantic)

ddlPizzaSize.SelectedIndex = 0

lblExpDate.Text = HTML_RIGHT_ALIGN & "Offer valid through " & _

FormatDateTime(Today().AddDays(7))

lblDiscountDesc.Text = FormatPercent(COUPON_DISCOUNT, 0) & " discount:"

Else

Session("mPizza") = 0

Session("lPizza") = 0

Session("gPizza") = 0

End If

End Sub

Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOrder.Click

Select Case ddlPizzaSize.SelectedItem.Value

Case "None" : Session("mPizza") = Session("mPizza") + 0

Case "Medium" : Session("mPizza") = Session("mPizza") + 1

Case "Large" : Session("lPizza") = Session("lPizza") + 1

Case "Gigantic" : Session("gPizza") = Session("gPizza") + 1

End Select

End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click

txtTest.Text = Session("mPizza") + Session("lPizza") + Session("gPizza")

End Sub

Nov 22 '05 #2

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

Similar topics

5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
3
by: Nhi Lam | last post by:
Hi, I understand that there are 3 modes in which I can configure the SessionStateModule. What I need is an out of process Session State store with fail over support. The "SQL Server Mode" seems...
2
by: John A Grandy | last post by:
for high traffic public websites , what are the proven options for session-state storage & management ? is an out-of-process state-server generally preferred over a sql-server ? what are the...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
5
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
11
by: Glenn | last post by:
Hi I've been experimenting with managing state using the Session object. I've created a simple WS with a couple of methods, one which sets a string value, another that retrieves it. Each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.