|
Hot-Link Menu in Right-Side Column |
Wal Mart Online → Store Pickup → Free Shipping![]() |
||||||||||||||||||||||||
|
Event Handler Code for Empty Cart ButtonThe next button on the DisplayCart.aspx we will deal with is the EmptyCart button. Pressing this button will both clear the CartContents from Session State, and clear the lstCart Listbox, indicating that all items have been deleted. Double-Click the Empty Cart button in Design View and enter the following code:
'Event Handler for Empty Shopping Cart
Protected Sub btnEmpty_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles btnEmpty.Click
'If the Cart isn't already empty:
If CartContents.Count > 0 Then
'Clear Session State & ListBox
CartContents.Clear
lstCart.Items.Clear
End If
End Sub
Run the program and add your favorite items. You can stop at 2 or 3, there probably isn't any point in going past 5 or 10. Press the Empty Button to make sure the ListBox clears. If it doesn't cut and paste the code above, and try again. Make sure the program is running smoothly before proceeding to the next step.
In order to continue with this guide, and begin the discussion on Emptying The Shopping Cart Press the Button below:
|
Home Visual Basic Introduction to VB.NET.NET Framework VS2008 IDE How VB is Compiled Start Visual Studio Windows Form App Save Your Work VB OOP ProgrammingVisual Basic Code Exit Code Button Event Code Coding RecommendationsIf/Then/Else Error List Window Comment Syntax Help Window Language Essentianl Built-In Data Types Declare Variables Declare ConstantsCode Arithmetic Expressions Assignment Statements Operator Precedence Type Casting Math Class String DeclarationConversion Functions Conversion Methods Formatting Functions String Formatting Variable Scope EnumerationsNullable Types Loop Constructs For Next LoopDo While Loop Do Until Loop Do...Loop-WhileDo...Loop-Until Exit Do | Exit For Do...LoopNested Loops Arrays Array DeclarationRnd( ) Function Listbox ControlKeyPressEventArgs Parallel Arrays Key Event ArgsDynamic Arrays Redimension ArraySet Breakpoint Start Debugger ReDim Preserve MultiDimensional Arrays DataGridView ControlLength and Sort Methods Structures Pad RightSplit Method IsNumeric Function Multiform Projects Add Form To Project Form Object Methods Form Show Method ShowDialog Method Form Close Method Form Accept Button Multiform Project Example ASP.NET Web Programming Create Data SourceConfigure Access Data Source Add Product Class Extract Local Database Data Order PageLoad VB CodeAdd New Web Page Set Start Page Display Cart Aspx CodeDisplay Cart Design View Sorted List Definition VB.NET Session State Create CartItem Class GetCartContents FunctionAdd To Cart Event Handler Remove Cart Item EventClear Cart Event Handler |