M
Mike
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
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